Enable sorting of the member courses
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 25 Feb 2015 18:15:54 +0000 (13:15 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 25 Feb 2015 18:15:54 +0000 (13:15 -0500)
Adding same functions from the photo positioning to the member courses.

.htaccess
Toolkit/Members.php
Toolkit/Members/Admin/EditCourses.php
Toolkit/Members/Admin/EditPhoto.php
Toolkit/Members/Photos.php
Toolkit/Members/libjs/edit-member-course.js
Toolkit/Members/libjs/edit-member-photos.js
Toolkit/Members/sortCourses.php [new file with mode: 0644]
Toolkit/Members/sortPhotos.php
Toolkit/Members/templates/editCourse.tpl

index 686c716..c7ab1b8 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -63,6 +63,7 @@ RewriteRule ^([A-Za-z0-9_-]*)/member-db-google-map/$ Toolkit/Members/memberDBGoo
 RewriteRule ^member-file/([0-9]*)/([0-9]*)/$ Toolkit/Members/memberFileDownload.php?mid=$1&fid=$2 [L]
 # Ajax call for saving photo repositioning
 RewriteRule ^member-save-photos/$ Toolkit/Members/sortPhotos.php [QSA,L]
+RewriteRule ^member-save-courses/$ Toolkit/Members/sortCourses.php [QSA,L]
 RewriteRule ^memberdb-site-map index.php?catid=0&memberDbSiteMap=1 [L]
 
 RewriteRule ^map/([0-9A-F]{6})/([0-9]*).png Toolkit/Maps/marker.php?color=$1&text=$2 [L]
index ea5bdb3..582d034 100644 (file)
@@ -248,8 +248,12 @@ class Toolkit_Members
             break;
 
         case 'courses' :
+            $GLOBALS['styleSheets'][]
+                = JQUERY_UI_CDN_CSS . '';
             $GLOBALS['bottomScripts'][]
                 = CKEDITOR_JS . '';
+            $GLOBALS['bottomScripts'][]
+                = MEDIA_APP_BASE_URL . 'libjs/jqueryui/1.8.13/js/jquery-ui-1.8.13.custom.min.js';
             $GLOBALS['bottomScripts'][]
                 = MEDIA_BASE_URL . 'Toolkit/Members/libjs/edit-member-course.js';
 
index fc2ba32..520a384 100644 (file)
@@ -1356,6 +1356,7 @@ class EditAdminCourse extends Toolkit_FormBuilder
 
         $this->accept($renderer);
         $this->view              = new stdClass();
+        $this->view->courseId    = $this->courseId;
         $this->view->showCurrImg = $this->showCurrImg;
         $this->view->form        = $renderer->toObject();
         $tEngine->compile($this->formTemplate);
index 24bb215..7a923bb 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-//     vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker syntax=php:
+//  vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker syntax=php:
 
 /**
  * Handles the photos tab in the member record
@@ -40,40 +40,40 @@ require_once BASE . 'Toolkit/Image/Server.php';
  */
 class Toolkit_Members_Admin_EditPhoto extends Toolkit_FormBuilder
 {
-       //      {{{ properties
-
-       /**
-        * The table name in the database used to store the data
-        *
-        * @var string
-        * @access public
-        */
-       public $tableName = 'member_photos';
-
-       /**
-        * Some special forms dont utlize this stylesheet
-        * Allow classes to override this setting so it doesn't
-        * get included
-        *
-        * @var boolean
-        * @access protected
-        */
-       protected $includeContactStyleSheet = false;
-
-       /**
-        * The template used to render the form
-        *
-        * @var string
-        * @access protected
-        */
-       protected $formTemplate = 'editPhoto.tpl';
+    //  {{{ properties
+
+    /**
+     * The table name in the database used to store the data
+     *
+     * @var string
+     * @access public
+     */
+    public $tableName = 'member_photos';
+
+    /**
+     * Some special forms dont utlize this stylesheet
+     * Allow classes to override this setting so it doesn't
+     * get included
+     *
+     * @var boolean
+     * @access protected
+     */
+    protected $includeContactStyleSheet = false;
+
+    /**
+     * The template used to render the form
+     *
+     * @var string
+     * @access protected
+     */
+    protected $formTemplate = 'editPhoto.tpl';
 
     /**
      * Id of photo in db
      * @var integer
      * @access protected
      */
-       protected $photoId;
+    protected $photoId;
 
     /**
      * Success message when a photo gets successfully updated
@@ -90,29 +90,29 @@ class Toolkit_Members_Admin_EditPhoto extends Toolkit_FormBuilder
      * @var array
      * @access protected
      */
-       protected $registeredRules = array();
+    protected $registeredRules = array();
 
-       //      }}}
-       //      {{{ __construct()
+    //  }}}
+    //  {{{ __construct()
 
-       /**
-        * Class constructor
-        *
-        * @param PDO                    $pdo         PHP Data Object
+    /**
+     * Class constructor
+     *
+     * @param PDO                    $pdo         PHP Data Object
      * @param Toolkit_Members_Photos $ll          Linked List of member photos
-        * @param string                 $formName    Form's name.
-        * @param string                 $method      (optional) Form's method
-        * @param string                 $action      (optional) Form's action.
-        * @param string                 $target      (optional) Form's target
-        * @param mixed                  $attributes  (optional) Extra attributes
-        * @param bool                   $trackSubmit (optional) Whether to track
+     * @param string                 $formName    Form's name.
+     * @param string                 $method      (optional) Form's method
+     * @param string                 $action      (optional) Form's action.
+     * @param string                 $target      (optional) Form's target
+     * @param mixed                  $attributes  (optional) Extra attributes
+     * @param bool                   $trackSubmit (optional) Whether to track
      *                                            if the form was submitted by
-        *                                                                                    adding a special hidden field.
-        *
-        * @access public
-        * @see    Toolkit_Members_Admin_EditPhotos
-        */
-       public function __construct(
+     *                                            adding a special hidden field.
+     *
+     * @access public
+     * @see    Toolkit_Members_Admin_EditPhotos
+     */
+    public function __construct(
         PDO $pdo,
         Toolkit_Members_Photos $ll,
         $formName,
@@ -122,7 +122,7 @@ class Toolkit_Members_Admin_EditPhoto extends Toolkit_FormBuilder
         $attributes = null,
         $trackSubmit = false
     ) {
-               parent::__construct(
+        parent::__construct(
             $formName,
             $method,
             $action,
@@ -132,172 +132,172 @@ class Toolkit_Members_Admin_EditPhoto extends Toolkit_FormBuilder
         );
 
         $this->dbh     = $pdo;
-               $this->photoId = $attributes['id'];
+        $this->photoId = $attributes['id'];
         $this->photos  = $ll;
-       }
-
-       //      }}}
-
-       //      {{{ configureDefaults()
-
-       /**
-        * Sets the defaults for elements in the form.
-        *
-        * @return void
-        * @access public
-        */
-       public function configureDefaults()
-       {
-               $photo    = $this->photos->findNode($this->photoId);
-               $defaults = array(
-                       'caption' => $photo->getCaption(),
-                       'pos'     => $photo->getPosition(),
-                       'pid'     => $photo->getId(),
-               );
-               $this->setupDefaults($defaults);
-       }
-
-       //      }}}
-       //      {{{ configureElements()
-
-       /**
-        * Setup the elements to use on the form.
-        *
+    }
+
+    //  }}}
+
+    //  {{{ configureDefaults()
+
+    /**
+     * Sets the defaults for elements in the form.
+     *
+     * @return void
+     * @access public
+     */
+    public function configureDefaults()
+    {
+        $photo    = $this->photos->findNode($this->photoId);
+        $defaults = array(
+            'caption' => $photo->getCaption(),
+            'pos'     => $photo->getPosition(),
+            'pid'     => $photo->getId(),
+        );
+        $this->setupDefaults($defaults);
+    }
+
+    //  }}}
+    //  {{{ configureElements()
+
+    /**
+     * Setup the elements to use on the form.
+     *
      * @param Config_Container $c application configuration
-        *
-        * @return void
-        * @access public
-        */
-       public function configureElements(Config_Container $c)
-       {
-               $positions = range(1, $this->photos->getListSize(true));
-               $options   = array_combine($positions, $positions);
+     *
+     * @return void
+     * @access public
+     */
+    public function configureElements(Config_Container $c)
+    {
+        $positions = range(1, $this->photos->getListSize(true));
+        $options   = array_combine($positions, $positions);
 
         $config =& $c->getItem('section', 'photos');
         $maxLength =& $config->getItem('directive', 'maxCaptionLength');
-               //      All Grouped Elements are created here.
-
-               //      All Elements are created here.  This includes group element definitions.
-               $cur = $this->photos->findNode($this->photoId);
-
-               $elements[] = array(
-                       'type' => 'hidden',
-                       'req'  => false,
-                       'name' => 'pid'
-               );
-               $elements[] = array(
-                       'type' => 'text',
-                       'req'  => false,
-                       'name' => 'caption',
+        //  All Grouped Elements are created here.
+
+        //  All Elements are created here.  This includes group element definitions.
+        $cur = $this->photos->findNode($this->photoId);
+
+        $elements[] = array(
+            'type' => 'hidden',
+            'req'  => false,
+            'name' => 'pid'
+        );
+        $elements[] = array(
+            'type' => 'text',
+            'req'  => false,
+            'name' => 'caption',
             'display' => 'Image Caption',
-                       'opts' => array(
-                               'class'     => 'text',
-                               'maxlength' => $maxLength->getContent(),
-                       ),
+            'opts' => array(
+                'class'     => 'text',
+                'maxlength' => $maxLength->getContent(),
+            ),
             'noCharLimit' => true
-               );
-               $elements[] = array(
-                       'type'    => 'select',
-                       'req'     => false,
-                       'name'    => 'pos',
-                       'display' => 'Position',
-                       'opts'    => $options,
-                       'att'     => array('id' => "pos{$cur->getPosition()}")
-               );
-               $elements[] = array(
-                       'type'    => 'submit',
-                       'req'     => false,
-                       'name'    => 'update',
-                       'display' => 'Update Photo',
-                       'opts'    => array('class' => 'submit')
-               );
-               $elements[] = array(
-                       'type'    => 'submit',
-                       'req'     => false,
-                       'name'    => 'delete',
-                       'display' => 'Delete Photo',
-                       'opts'    => array('class' => 'photoDelete')
-               );
-
-               $this->setupElements($elements);
-       }
-
-       //      }}}
+        );
+        $elements[] = array(
+            'type'    => 'select',
+            'req'     => false,
+            'name'    => 'pos',
+            'display' => 'Position',
+            'opts'    => $options,
+            'att'     => array('id' => "pos{$cur->getPosition()}")
+        );
+        $elements[] = array(
+            'type'    => 'submit',
+            'req'     => false,
+            'name'    => 'update',
+            'display' => 'Update Photo',
+            'opts'    => array('class' => 'submit')
+        );
+        $elements[] = array(
+            'type'    => 'submit',
+            'req'     => false,
+            'name'    => 'delete',
+            'display' => 'Delete Photo',
+            'opts'    => array('class' => 'photoDelete')
+        );
+
+        $this->setupElements($elements);
+    }
+
+    //  }}}
     //  {{{ configureForm()
 
     /**
-        * helper function to set up entire form definition
-        *
+     * helper function to set up entire form definition
+     *
      * @param Config_Container $c application configuration
-        *
-        * @return void
-        * @access public
+     *
+     * @return void
+     * @access public
      */
     public function configureForm(Config_Container $c)
     {
         $this->configureElements($c);
         $this->configureDefaults();
-               $this->configureRules($c);
+        $this->configureRules($c);
     }
 
     //  }}}
-       //      {{{ configureRules()
+    //  {{{ configureRules()
 
     /**
      * Configures any rules we want to use on the form
-        *
+     *
      * @param Config_Container $c application configuration
      *
      * @access public
      * @return void
      */
-       public function configureRules(Config_Container $c)
-       {
-               $r = array();
+    public function configureRules(Config_Container $c)
+    {
+        $r = array();
 
         $config =& $c->getItem('section', 'photos');
         $maxLength =& $config->getItem('directive', 'maxCaptionLength');
 
-               $r[] = array(
-                       'element'    => 'caption',
-                       'message'    => "ERROR: Please limit caption to {$maxLength->getContent()} characters!",
-                       'type'       => 'maxlength',
-                       'format'     => $maxLength->getContent(),
-                       'validation' => $this->validationType,
-                       'reset'      => false,
-                       'force'      => false
-               );
-               $this->setupRules($r);
-       }
-
-       //      }}}
-
-       //      {{{ processData()
-
-       /**
-        * Handles setting up the from processing and which function to get it done
-        *
-        * @param array $values submitted values from the form
-        *
-        * @return array Submitted values from the form.
-        * @access protected
-        */
-       protected function processData($values)
-       {
-               if (!$this->getSubmitValue('delete')) {
+        $r[] = array(
+            'element'    => 'caption',
+            'message'    => "ERROR: Please limit caption to {$maxLength->getContent()} characters!",
+            'type'       => 'maxlength',
+            'format'     => $maxLength->getContent(),
+            'validation' => $this->validationType,
+            'reset'      => false,
+            'force'      => false
+        );
+        $this->setupRules($r);
+    }
+
+    //  }}}
+
+    //  {{{ processData()
+
+    /**
+     * Handles setting up the from processing and which function to get it done
+     *
+     * @param array $values submitted values from the form
+     *
+     * @return array Submitted values from the form.
+     * @access protected
+     */
+    protected function processData($values)
+    {
+        if (!$this->getSubmitValue('delete')) {
             unset($values['update']);
             $photo = $this->photos->findNode($values['pid']);
             try {
-                //     This value might be removed by JS so make sure
-                //     its in place before you try to update the positions
+                //  This value might be removed by JS so make sure
+                //  its in place before you try to update the positions
                 //
-                //     This is taken out in JS instead of just hiding it
-                //     b/c if the image gets dragged and repositioned,
-                //     and then the caption is updated, the old positions
-                //     in the hidden select list will override all the
-                //     newly positioned photos.
-                //     This value might be removed by JS so make sure
-                //     its in place before you try to update the positions
+                //  This is taken out in JS instead of just hiding it
+                //  b/c if the image gets dragged and repositioned,
+                //  and then the caption is updated, the old positions
+                //  in the hidden select list will override all the
+                //  newly positioned photos.
+                //  This value might be removed by JS so make sure
+                //  its in place before you try to update the positions
                 $this->dbh->beginTransaction();
                 if (isset($values['pos']) && $values['pos'] != $photo->getPosition()) {
                     $this->photos->moveNode($photo->getId(), $values['pos']);
@@ -311,14 +311,14 @@ class Toolkit_Members_Admin_EditPhoto extends Toolkit_FormBuilder
                 $this->dbh->rollback();
                 return Toolkit_Common::handleError($e);
             }
-               }
+        }
 
         header('Location:' . $this->getAttribute('action'));
-       }
+    }
 
-       //      }}}
+    //  }}}
 
-       //      {{{ setupRenderers()
+    //  {{{ setupRenderers()
 
     /**
      * Set up the rendering engine we are going to use to display this form
@@ -328,60 +328,60 @@ class Toolkit_Members_Admin_EditPhoto extends Toolkit_FormBuilder
      * @return void
      * @access protected
      */
-       protected function setupRenderers(HTML_Template_Flexy $tEngine)
-       {
-               $renderer = new HTML_QuickForm_Renderer_ObjectFlexy($tEngine);
-
-               $this->accept($renderer);
-               $this->view          = new stdClass();
-               $this->view->photoId = $this->photoId;
-               $this->view->form    = $renderer->toObject();
-               $photo               = $this->photos->findNode($this->photoId);
-               $this->view->pending = $photo->getPending();
-               $this->view->img_alt = $photo->getCaption();
-               $this->view->img_src = MEMBER_PHOTOS . $photo->getImage();
-               $tEngine->compile($this->formTemplate);
-       }
-
-       //      }}}
-
-       //      {{{ toHtml()
-
-       /**
-        * Renders the form
-        *
-        * sets the page the form should be redirected to instead of coming back
-        * around to itself.
-        *
+    protected function setupRenderers(HTML_Template_Flexy $tEngine)
+    {
+        $renderer = new HTML_QuickForm_Renderer_ObjectFlexy($tEngine);
+
+        $this->accept($renderer);
+        $this->view          = new stdClass();
+        $this->view->photoId = $this->photoId;
+        $this->view->form    = $renderer->toObject();
+        $photo               = $this->photos->findNode($this->photoId);
+        $this->view->pending = $photo->getPending();
+        $this->view->img_alt = $photo->getCaption();
+        $this->view->img_src = MEMBER_PHOTOS . $photo->getImage();
+        $tEngine->compile($this->formTemplate);
+    }
+
+    //  }}}
+
+    //  {{{ toHtml()
+
+    /**
+     * Renders the form
+     *
+     * sets the page the form should be redirected to instead of coming back
+     * around to itself.
+     *
      * @param HTML_Template_Flexy  $tEngine Templating Engine
      * @param Cache_Lite           $cache   Caching Engine
      * @param Toolkit_Image_Server $is      Image Server
      * @param Config_Container     $c       Application configuration
      *
-        * @return string The rendered form
-        * @access public
-        */
-       public function toHtml(
+     * @return string The rendered form
+     * @access public
+     */
+    public function toHtml(
         HTML_Template_Flexy $tEngine,
         Cache_Lite $cache,
         Toolkit_Image_Server $is,
         Config_Container $c
     ) {
-               if ($this->validate()) {
+        if ($this->validate()) {
             $res = $cache->remove("Member-{$_GET['id']}", 'Profile');
 
             if ($this->getSubmitValue('delete')) {
                 $this->photos->removeNode($is, $c, $this->getSubmitValue('pid'));
             }
 
-                       $this->process(array(&$this, 'processData'), $this->mergeFiles);
-               }
+            $this->process(array(&$this, 'processData'), $this->mergeFiles);
+        }
 
-               $this->setupRenderers($tEngine);
+        $this->setupRenderers($tEngine);
 
-               return $tEngine->bufferedOutputObject($this->view);
-       }
+        return $tEngine->bufferedOutputObject($this->view);
+    }
 
-       //      }}}
+    //  }}}
 }
 ?>
index c5cfb42..4834bbf 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-//     vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker syntax=php:
+//  vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker syntax=php:
 
 /**
  * Linked list (LL) implementation of member photos
@@ -19,7 +19,7 @@
  * @version   CVS: $Id: Photos.php,v 1.13 2010/05/25 14:01:18 jamie Exp $
  * @link      http://demo.gaslightmedia.com
  * @see       Structures/LinkedList/Double.php
- *                       Toolkit/Members/Photos/Photo.php
+ *            Toolkit/Members/Photos/Photo.php
  */
 
 /**
  */
 class Toolkit_Members_Photos extends Structures_LinkedList_Double
 {
-       //      {{{     properties
+    //  {{{ properties
 
     /**
      * DB id of member whos photos we are manipulating with this linked list
      * @var    integer
      * @access protected
      */
-       protected $mid;
+    protected $mid;
 
-       //      }}}
-       //      {{{     __construct()
+    //  }}}
+    //  {{{ __construct()
 
     /**
      * Constructor
@@ -53,26 +53,26 @@ class Toolkit_Members_Photos extends Structures_LinkedList_Double
      * @param Structures_LinkedList_DoubleNode $root Linked List node object
      * @param integer                          $mid  id of member we want
      *                                               to prepare the list for
-        *
+     *
      * @access public
      * @return void
      */
-       function __construct(
+    function __construct(
         Structures_LinkedList_DoubleNode $root = null,
         $mid = null
     ) {
-               parent::__construct($root);
-               $this->setMember($mid);
+        parent::__construct($root);
+        $this->setMember($mid);
         /*
-               if (is_numeric($mid)) {
-                       $this->createMemberList($mid);
-               }
+        if (is_numeric($mid)) {
+            $this->createMemberList($mid);
+        }
         */
-       }
+    }
 
-       //      }}}
+    //  }}}
 
-       //      {{{     createMemberList()
+    //  {{{ createMemberList()
 
     /**
      * Creates a linked list from all the photos a member has in the db.
@@ -80,111 +80,111 @@ class Toolkit_Members_Photos extends Structures_LinkedList_Double
      * @param PDO              $dbh   PHP Data Object
      * @param Config_Container $c     Member configuration
      * @param string           $order The order to make the linked list in
-        *
+     *
      * @return boolean false on error
      * @access public
      */
-       public function createMemberList(
+    public function createMemberList(
         PDO $dbh,
         Config_Container $c,
         $order = 'pos'
     ) {
-               if (!ctype_digit((string) $this->mid)) {
-                       return;
-               }
+        if (!ctype_digit((string) $this->mid)) {
+            return;
+        }
 
         //  Make sure the list is actually empty before you recreate it
         //  otherwise you can end up w/ duplicate values in the LL
         $this->emptyList();
 
-               $safeOrder = array('pos', 'id');
-               if (!in_array($order, $safeOrder)) {
-                       $order = 'pos';
-               }
-               try {
-                       //      Get each photo tuple from the member_photos table.
-                       $sql = "
-                               SELECT *
-                                 FROM member_photos
-                                WHERE member_id = :member_id
-                                ORDER BY $order";
-
-                       $stmt = $dbh->prepare($sql);
-                       $stmt->bindParam(':member_id', $this->mid, PDO::PARAM_INT);
-                       $stmt->execute();
-
-                       while ($row = $stmt->fetch()) {
-                               //      Create a new node w/ all the data we just extracted.
-                               $node = $this->createNode($row);
+        $safeOrder = array('pos', 'id');
+        if (!in_array($order, $safeOrder)) {
+            $order = 'pos';
+        }
+        try {
+            //  Get each photo tuple from the member_photos table.
+            $sql = "
+                SELECT *
+                  FROM member_photos
+                 WHERE member_id = :member_id
+                 ORDER BY $order";
+
+            $stmt = $dbh->prepare($sql);
+            $stmt->bindParam(':member_id', $this->mid, PDO::PARAM_INT);
+            $stmt->execute();
+
+            while ($row = $stmt->fetch()) {
+                //  Create a new node w/ all the data we just extracted.
+                $node = $this->createNode($row);
                 $node->setDbh($dbh);
-                               //      Sets up any pending data the photo might currently have.
-                               $node->setPendingData($c);
-                               //      Add the photo node to the end of the linked list.
-                               $res = $this->appendNode($node);
-                       }
+                //  Sets up any pending data the photo might currently have.
+                $node->setPendingData($c);
+                //  Add the photo node to the end of the linked list.
+                $res = $this->appendNode($node);
+            }
 
-               } catch (PDOException $e) {
-                       return Toolkit_Common::handleError($e);
-               }
-       }
+        } catch (PDOException $e) {
+            return Toolkit_Common::handleError($e);
+        }
+    }
 
-       //      }}}
-       //      {{{     createNode()
+    //  }}}
+    //  {{{ createNode()
 
     /**
      * Creates a new linked list node object
      *
      * @param array $data Data to populate the new node with
-        *
+     *
      * @return Toolkit_Members_Photos_Photo linked list node
      * @access public
      */
-       public function &createNode(array $data)
-       {
-               return new Toolkit_Members_Photos_Photo($data);
-       }
+    public function &createNode(array $data)
+    {
+        return new Toolkit_Members_Photos_Photo($data);
+    }
 
-       //      }}}
+    //  }}}
 
-       //      {{{     getListSize()
+    //  {{{ getListSize()
 
     /**
      * Get how many nodes are currently in the linked list
      *
      * @param boolean $filterPending Include pending photos in the count
-        *
+     *
      * @return integer number of nodes in the linked list
      * @access public
      */
-       public function getListSize($filterPending = false)
-       {
-               $size = 0;
-               $cur  = $this->rewind();
-
-               //      If the current node is null, then we have no nodes
-               //      in the linked list.  return the empty size.
-               //      Else we have at least one node in the linked list.
-               if (is_null($cur)) {
-                       return $size;
-               }
-
-               //      Add one to the size of the list for every
-               //      node we encounter.
-               do {
-                       if ($filterPending) {
-                               if (!$cur->getPending()) {
-                                       ++$size;
-                               }
-                       } else {
-                               ++$size;
-                       }
-               } while ($cur = $this->next());
-
-               return $size;
-       }
-
-       //      }}}
-       //      {{{     getMemberId()
+    public function getListSize($filterPending = false)
+    {
+        $size = 0;
+        $cur  = $this->rewind();
+
+        //  If the current node is null, then we have no nodes
+        //  in the linked list.  return the empty size.
+        //  Else we have at least one node in the linked list.
+        if (is_null($cur)) {
+            return $size;
+        }
+
+        //  Add one to the size of the list for every
+        //  node we encounter.
+        do {
+            if ($filterPending) {
+                if (!$cur->getPending()) {
+                    ++$size;
+                }
+            } else {
+                ++$size;
+            }
+        } while ($cur = $this->next());
+
+        return $size;
+    }
+
+    //  }}}
+    //  {{{ getMemberId()
 
     /**
      * Get which member this linked list is for
@@ -192,83 +192,83 @@ class Toolkit_Members_Photos extends Structures_LinkedList_Double
      * @return integer id of member we are dealing with
      * @access public
      */
-       public function getMemberId()
-       {
-               return $this->mid;
-       }
+    public function getMemberId()
+    {
+        return $this->mid;
+    }
 
-       //      }}}
+    //  }}}
 
-       //      {{{     findNode()
+    //  {{{ findNode()
 
     /**
      * find a node from the linked list
      *
      * @param integer $target Id of photo you are searching for
-        *
+     *
      * @return mixed Toolkit_Members_Photos_Photo object if present, else false
      * @access public
      */
-       public function &findNode($target)
-       {
-               $this->end();
-               $startingId = $this->current->getId();
+    public function &findNode($target)
+    {
+        $this->end();
+        $startingId = $this->current->getId();
 
-               if ($target == $startingId) {
-                       return $this->current;
-               }
+        if ($target == $startingId) {
+            return $this->current;
+        }
 
-               while ($curr = $this->previous()) {
-                       if ($target == $curr->getId()) {
-                               return $curr;
-                       }
-               }
+        while ($curr = $this->previous()) {
+            if ($target == $curr->getId()) {
+                return $curr;
+            }
+        }
 
-               return false;
-       }
+        return false;
+    }
 
-       //      }}}
+    //  }}}
 
-       //      {{{     moveNode()
+    //  {{{ moveNode()
 
     /**
      * Adjust nodes position in the linked list
      *
      * @param integer $pid id of photo you want to move
      * @param integer $pos new position you want to move to
-        *
+     *
      * @return void
      * @access public
      */
-       public function moveNode($pid, $pos)
-       {
-               $node   = $this->findNode($pid);
-               $oldPos = $node->getPosition();
-
-               if ($this->getListSize()) {
-                       $cur = $this->rewind();
-                       do {
-                               if ($cur->getId() == $pid) {
-                                       $cur->setPosition($pos);
-                               } else {
-                                       $curPos = $cur->getPosition();
-                                       if ($pos > $oldPos) {
-                                               if ($curPos <= $pos && $curPos > $oldPos) {
-                                                       $cur->setPosition($curPos - 1);
-                                               }
-                                       } elseif ($pos < $oldPos) {
-                                               if ($curPos >= $pos && $curPos < $oldPos) {
-                                                       $cur->setPosition($curPos + 1);
-                                               }
-                                       }
-                               }
-                       } while ($cur = $this->next());
-               }
-       }
-
-       //      }}}
-
-       //      {{{     removeNode()
+    public function moveNode($pid, $pos)
+    {
+        $node   = $this->findNode($pid);
+        $oldPos = $node->getPosition();
+
+        if ($this->getListSize()) {
+            $cur = $this->rewind();
+            do {
+                if ($cur->getId() == $pid) {
+                    $cur->setPosition($pos);
+                } else {
+                    $curPos = $cur->getPosition();
+                    if ($pos > $oldPos) {
+                        if ($curPos <= $pos && $curPos > $oldPos) {
+                            $cur->setPosition($curPos - 1);
+                        }
+                    } elseif ($pos < $oldPos) {
+                        if ($curPos >= $pos && $curPos < $oldPos) {
+                            $cur->setPosition($curPos + 1);
+                        }
+                    }
+                }
+            } while ($cur = $this->next());
+        }
+    }
+
+    //  }}}
+
+    //  {{{ removeNode()
 
     /**
      * Removes a node from the linked list
@@ -276,59 +276,59 @@ class Toolkit_Members_Photos extends Structures_LinkedList_Double
      * @param Toolkit_Image_Server $is     Image Server Object
      * @param Config_Container     $c      Member configuration
      * @param integer              $target Id of photo you want to remove
-        *
+     *
      * @return boolean false on error
      * @access public
      */
-       public function removeNode(
+    public function removeNode(
         Toolkit_Image_Server $is,
         Config_Container $c,
         $target
     ) {
-               $node = $this->findNode($target);
-               if (!$node) {
-                       return false;
-               }
+        $node = $this->findNode($target);
+        if (!$node) {
+            return false;
+        }
 
-               $node->remove($is, $c);
-               $remNodePos = $node->getPosition();
+        $node->remove($is, $c);
+        $remNodePos = $node->getPosition();
 
-               //      only try and update positions in the linked list if     there are nodes that
-               //      will still exists after this node is removed ie.  size is greater than 1
-               if ($this->getListSize() > 1) {
-                       $cur = $this->rewind();
-                       do {
-                               if ($cur->getPosition() > $remNodePos) {
-                                       $cur->setPosition($cur->getPosition() - 1);
-                               }
-                       } while ($cur = $this->next());
-               }
+        //  only try and update positions in the linked list if there are nodes that
+        //  will still exists after this node is removed ie.  size is greater than 1
+        if ($this->getListSize() > 1) {
+            $cur = $this->rewind();
+            do {
+                if ($cur->getPosition() > $remNodePos) {
+                    $cur->setPosition($cur->getPosition() - 1);
+                }
+            } while ($cur = $this->next());
+        }
 
-               $this->deleteNode($node);
-       }
+        $this->deleteNode($node);
+    }
 
-       //      }}}
+    //  }}}
 
-       //      {{{     setMember()
+    //  {{{ setMember()
 
     /**
      * Sets which member we are working with
      *
      * @param integer $mid id of member
-        *
+     *
      * @access public
      * @return void
      */
-       public function setMember($mid)
-       {
-               if (ctype_digit((string) $mid)) {
-                       $this->mid = $mid;
-               }
-       }
+    public function setMember($mid)
+    {
+        if (ctype_digit((string) $mid)) {
+            $this->mid = $mid;
+        }
+    }
 
-       //      }}}
+    //  }}}
 
-       //      {{{     emptyList()
+    //  {{{ emptyList()
 
     /**
      * Deletes all nodes from a list
@@ -336,14 +336,14 @@ class Toolkit_Members_Photos extends Structures_LinkedList_Double
      * @access public
      * @return void
      */
-       public function emptyList()
-       {
-               $this->end();
-               while ($cur = $this->current()) {
-                       $this->deleteNode($cur);
-               }
-       }
-
-       //      }}}
+    public function emptyList()
+    {
+        $this->end();
+        while ($cur = $this->current()) {
+            $this->deleteNode($cur);
+        }
+    }
+
+    //  }}}
 }
 ?>
index 79ac5bd..168d5bb 100755 (executable)
@@ -1,20 +1,51 @@
-var MemberPackages =
+var MemberCourses =
 {
     init: function()
     {
+        $('input[name="remove_rmv"]').click(MemberCourses.remove);
+
         if (CKEDITOR.env.isCompatible) {
             $("textarea.ckeditor").each(function() {
                 CKEDITOR.replace(
                     $(this).attr('id'),
                     {
                         toolbar : 'LimitedToolset',
-                        width : 300,
-                        height : 200
+                        width : 350,
+                        height : 400
                     }
                 );
             });
         }
+
+        $('div.container').sortable({
+            placeholder: 'ui-state-highlight',
+            //handle: 'div.packageItem',
+            opacity: 0.6,
+            revert: true,
+            scroll: true,
+            tolerance: 'pointer',
+            zIndex: 5,
+            axis: 'y',
+            cursor: 'n-resize',
+            update: MemberCourses.updatePos
+        });
+    },
+
+    updatePos: function(event, ui)
+    {
+        var url = '../member-save-courses/?' + $(this).sortable('serialize');
+        //  Update the course positions through AJAX.
+        $.get(url, function(data) {
+            $('.movable').effect('highlight', {}, 700);
+        });
+    },
+
+    remove: function(event)
+    {
+        if (!confirm('Are you sure you wish to remove this course?\nThis is not reversible!')) {
+            event.preventDefault();
+        }
     }
 }
 
-$(document).ready(MemberPackages.init);
+$(document).ready(MemberCourses.init);
index ae73b11..59913c4 100755 (executable)
@@ -1,58 +1,58 @@
 var MemberPhotos =
 {
-       init: function()
-       {
-               $('.photoDelete').click(MemberPhotos.remove);
-
-               //      Make just the photos uploaded have an additional class
-               //      on them, so we can make them movable later.
-               $(".photoItem:not(.photoUploadForm)").addClass('movable');
-
-               //      Update the text on the update button.
-               //      Since they have javascript on, the only update
-               //      they will actually do on the form is the caption.
-               //      They won't be updating the position through the select list.
-               $(":submit[name='update']").val('Update Caption Text');
-
-               //      Remove all the positioning select elemnts
-               //      so they can't override any new position adjustments
-               //      done through drag and drop.
-               $('.position').remove();
-
-               //      Add a message for users to tell them how to 
-               //      reposition thier images.
-               $('#photoList').before('<div id="pos-info">Click and drag images to reorder positions. Image positions are saved when the fields flash yellow</div>');
-
-               $('div.container').sortable({
-                       placeholder: 'ui-state-highlight',
-                       handle: 'img.thumb',
-                       opacity: 0.6,
-                       revert: true,
-                       scroll: true,
-                       tolerance: 'pointer',
-                       zIndex: 5,
-                       axis: 'y',
-                       cursor: 'n-resize',
-                       update: MemberPhotos.updatePos
-               });
-               $('img.thumb').disableSelection();
-       },
-
-       updatePos: function(event, ui)
-       {
-               var url = '../member-save-photos/?' + $(this).sortable('serialize');
-               //      Update the photo positions through AJAX.
-               $.get(url, function(data) {
-                       $('.movable').effect('highlight', {}, 700);
-               });
-       },
-
-       remove: function(event)
-       {
-               if (!confirm('Are you sure you wish to remove this photo?\nThis is not reversible!')) {
-                       event.preventDefault();
-               }
-       }
+    init: function()
+    {
+        $('.photoDelete').click(MemberPhotos.remove);
+
+        //  Make just the photos uploaded have an additional class
+        //  on them, so we can make them movable later.
+        $(".photoItem:not(.photoUploadForm)").addClass('movable');
+
+        //  Update the text on the update button.
+        //  Since they have javascript on, the only update
+        //  they will actually do on the form is the caption.
+        //  They won't be updating the position through the select list.
+        $(":submit[name='update']").val('Update Caption Text');
+
+        //  Remove all the positioning select elemnts
+        //  so they can't override any new position adjustments
+        //  done through drag and drop.
+        $('.position').remove();
+
+        //  Add a message for users to tell them how to
+        //  reposition thier images.
+        $('#photoList').before('<div id="pos-info">Click and drag images to reorder positions. Image positions are saved when the fields flash yellow</div>');
+
+        $('div.container').sortable({
+            placeholder: 'ui-state-highlight',
+            handle: 'img.thumb',
+            opacity: 0.6,
+            revert: true,
+            scroll: true,
+            tolerance: 'pointer',
+            zIndex: 5,
+            axis: 'y',
+            cursor: 'n-resize',
+            update: MemberPhotos.updatePos
+        });
+        $('img.thumb').disableSelection();
+    },
+
+    updatePos: function(event, ui)
+    {
+        var url = '../member-save-photos/?' + $(this).sortable('serialize');
+        //  Update the photo positions through AJAX.
+        $.get(url, function(data) {
+            $('.movable').effect('highlight', {}, 700);
+        });
+    },
+
+    remove: function(event)
+    {
+        if (!confirm('Are you sure you wish to remove this photo?\nThis is not reversible!')) {
+            event.preventDefault();
+        }
+    }
 };
 
 $(document).ready(MemberPhotos.init);
diff --git a/Toolkit/Members/sortCourses.php b/Toolkit/Members/sortCourses.php
new file mode 100644 (file)
index 0000000..7e1f000
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+/**
+ * File Doc Comment
+ *
+ * PHP version 5
+ *
+ * @category MembersDB
+ * @package  Toolkit_Members
+ * @author   Jamie Kahgee <jamie.kahgee@gmail.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  CVS: $Id: sortCourses.php,v 1.5 2009/12/29 14:17:49 jamie Exp $
+ * @link     http://demo.gaslightmedia.com
+ */
+
+require_once '../../setup.phtml';
+//  Make sure the users browser doesn't cache the result.
+
+//  Time in the past.
+header('Expires: Wed, 23 Dec 1980 00:30::00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+header('Cache-Control: no-cache, must-revalidate');
+header('Pragma: no-cache');
+
+if (!is_array($_GET['courses'])) {
+    return;
+}
+$newOrder = $_GET['courses'];
+
+$dbh = Toolkit_Database::getInstance();
+try {
+    $dbh->beginTransaction();
+
+    $sql = "
+        UPDATE member_golf
+           SET pos = :pos
+         WHERE id  = :id";
+    $stmt = $dbh->prepare($sql);
+    foreach ($newOrder as $k => &$v) {
+        $pos = $k + 1;
+        $stmt->bindParam(':pos', $pos, PDO::PARAM_INT);
+        $stmt->bindParam(':id', $v, PDO::PARAM_INT);
+        $stmt->execute();
+    }
+    $dbh->commit();
+    echo true;
+} catch (PDOException $e) {
+    $dbh->rollBack();
+    echo 'PDO Exception Caught.  ';
+    echo 'Error with the database:<br>';
+    echo 'Error: ' . $e->getMessage() . '<br>';
+    echo 'File: ' . $e->getFile() . '<br>';
+    echo 'Line: ' . $e->getLine() . '<br>';
+    print_r($dbh->errorInfo());
+}
+?>
index 72852c7..1e84d99 100644 (file)
@@ -7,49 +7,49 @@
  * @category MembersDB
  * @package  Toolkit_Members
  * @author   Jamie Kahgee <jamie.kahgee@gmail.com>
- * @license     http://www.gaslightmedia.com Gaslightmedia
+ * @license  http://www.gaslightmedia.com Gaslightmedia
  * @version  CVS: $Id: sortPhotos.php,v 1.5 2009/12/29 14:17:49 jamie Exp $
- * @link        http://demo.gaslightmedia.com
+ * @link     http://demo.gaslightmedia.com
  */
 
 require_once '../../setup.phtml';
-//     Make sure the users browser doesn't cache the result.
+//  Make sure the users browser doesn't cache the result.
 
-//     Time in the past.
+//  Time in the past.
 header('Expires: Wed, 23 Dec 1980 00:30::00 GMT');
 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
 header('Cache-Control: no-cache, must-revalidate');
 header('Pragma: no-cache');
 
 if (!is_array($_GET['photos'])) {
-       return;
+    return;
 }
 $newOrder = $_GET['photos'];
 
 $dbh = Toolkit_Database::getInstance();
 try {
-       $dbh->beginTransaction();
+    $dbh->beginTransaction();
 
-       $sql = "
+    $sql = "
         UPDATE member_photos
            SET pos = :pos
          WHERE id  = :id";
-       $stmt = $dbh->prepare($sql);
-       foreach ($newOrder as $k => &$v) {
-               $pos = $k + 1;
-               $stmt->bindParam(':pos', $pos, PDO::PARAM_INT);
-               $stmt->bindParam(':id', $v, PDO::PARAM_INT);
-               $stmt->execute();
-       }
-       $dbh->commit();
-       echo true;
+    $stmt = $dbh->prepare($sql);
+    foreach ($newOrder as $k => &$v) {
+        $pos = $k + 1;
+        $stmt->bindParam(':pos', $pos, PDO::PARAM_INT);
+        $stmt->bindParam(':id', $v, PDO::PARAM_INT);
+        $stmt->execute();
+    }
+    $dbh->commit();
+    echo true;
 } catch (PDOException $e) {
-       $dbh->rollBack();
-       echo 'PDO Exception Caught.  ';
-       echo 'Error with the database:<br>';
-       echo 'Error: ' . $e->getMessage() . '<br>';
-       echo 'File: ' . $e->getFile() . '<br>';
-       echo 'Line: ' . $e->getLine() . '<br>';
-       print_r($dbh->errorInfo());
+    $dbh->rollBack();
+    echo 'PDO Exception Caught.  ';
+    echo 'Error with the database:<br>';
+    echo 'Error: ' . $e->getMessage() . '<br>';
+    echo 'File: ' . $e->getFile() . '<br>';
+    echo 'Line: ' . $e->getLine() . '<br>';
+    print_r($dbh->errorInfo());
 }
 ?>
index 15bb6be..2f505df 100644 (file)
@@ -1,4 +1,5 @@
-<div class="packageItem packageUploadForm">
+<div id="courses_{courseId}" class="packageItem packageUploadForm">
+    <span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
     {form.javascript:h}
     {form.outputHeader():h}
     {form.hidden:h}