Exemplo n.º 1
0
 function &singleton()
 {
     static $baskets;
     if (isset($_COOKIE['basketID']) && is_numeric($_COOKIE['basketID'])) {
         $sql = "SELECT COUNT(*) AS total\n                      FROM basket\n                      WHERE basketID=" . $_COOKIE['basketID'];
         $result = $this->db->getOne($sql);
         if (!PEAR::isError($result) && is_numeric($result) && $result > 0) {
             $basketID = $_COOKIE['basketID'];
             if (isset($baskets[$basketID]) && is_object($baskets[$basketID])) {
                 // Do nothing - the basket already exists
             } else {
                 $baskets[$basketID] =& new JxBasket($basketID);
             }
         } else {
             $basketID = 0;
         }
     }
     if ($basketID == 0) {
         $basketID = JxCreateId('basket', 'basketID');
         $userID = $user->userID;
         $posted = time();
         $type = 0;
         if ((int) $basketID > 0) {
             $sql = "INSERT INTO basket\n                          SET basketID='" . (int) $basketID . "',\n                              userID='" . $userID . "',\n                              posted='" . $posted . "',\n                              type='" . $type . "'";
             $result = $this->db->query($sql);
             if (PEAR::isError($result)) {
                 return PEAR::raiseError('Unable to create basket');
             } else {
                 JxHttp::setCookie('basketID', $basketID);
             }
         }
         $baskets[$basketID] =& new JxBasket($basketID);
     }
     return $baskets[$basketID];
 }
Exemplo n.º 2
0
 function JxAdminPhotosImages()
 {
     if (JX_PATH_MODE == JX_PATH_MODE_HOSTED) {
         $this->path = JX_HOSTED_PATH;
     } else {
         $this->path = JX_BASE_PATH;
     }
     $this->JxAdmin();
     $this->table = 'photos_images';
     $this->label = 'Photos Images';
     $this->primaryKey = 'imageID';
     $this->titles = array('Thumb', 'Caption', 'Posted');
     $this->showFields = array('imageID', 'caption', 'posted');
     $this->options['disableEdit'] = 1;
     $sql = "SELECT *\n                  FROM photos_albums\n                  ORDER BY title";
     $result = $this->db->query($sql);
     if (!DB::isError($result) && $result->numRows()) {
         $albums = array();
         while ($row = $result->fetchRow()) {
             $albums[$row['albumID']] = stripslashes($row['title']);
         }
     }
     $this->addField(array('name' => 'albums[]', 'label' => 'Albums', 'type' => 'JxFieldCheckbox', 'required' => 'true', 'list' => $albums, 'value' => $_POST['albums']));
     $this->addField(array('name' => 'imageID', 'type' => 'JxFieldHidden', 'required' => 'true', 'value' => JxCreateId('photos_images', 'imageID')));
     $this->addField(array('name' => 'userID', 'type' => 'JxFieldHidden', 'required' => 'true', 'value' => $this->user->userID));
     $this->addField(array('name' => 'image', 'label' => 'Image', 'type' => 'JxFieldFile', 'required' => 'true', 'value' => $this->user->userID));
     $this->addField(array('name' => 'caption', 'label' => 'Caption', 'type' => 'JxFieldText', 'size' => '45', 'required' => 'true', 'value' => $_POST['caption']));
     $this->addField(array('name' => 'posted', 'type' => 'JxFieldHidden', 'required' => 'true', 'value' => time()));
 }
Exemplo n.º 3
0
 function JxAdminGroups()
 {
     $this->JxAdmin();
     $this->table = 'groups';
     $this->primaryKey = 'groupID';
     $this->titles = array('Group ID', 'Name');
     $this->showFields = array('groupID', 'name');
     $this->label = 'System Groups';
     $this->addField(array('type' => 'JxFieldHidden', 'name' => 'groupID', 'value' => JxCreateId('groups', 'groupID', 10, 99), 'required' => true));
     $this->addField(array('type' => 'JxFieldText', 'name' => 'name', 'label' => 'Name', 'size' => 35, 'value' => $_POST['name'], 'required' => true));
 }
Exemplo n.º 4
0
 function JxAdminPhotosAlbums()
 {
     $this->JxAdmin();
     $this->table = 'photos_albums';
     $this->label = 'Photo Albums';
     $this->primaryKey = 'albumID';
     $this->titles = array('AlbumID', 'Title', 'Posted');
     $this->showFields = array('albumID', 'title', 'posted');
     $this->addField(array('name' => 'albumID', 'label' => 'albumID', 'type' => 'JxFieldHidden', 'required' => 'true', 'value' => JxCreateId('photos_albums', 'albumID')));
     $this->addField(array('name' => 'title', 'label' => 'Title', 'type' => 'JxFieldText', 'size' => '45', 'required' => 'true', 'value' => $_POST['title']));
     $this->addField(array('name' => 'description', 'label' => 'Description', 'type' => 'JxFieldTextarea', 'cols' => '40', 'rows' => '10', 'value' => $_POST['description']));
     $this->addField(array('name' => 'userID', 'type' => 'JxFieldHidden', 'required' => 'true', 'value' => $this->user->userID));
     $this->addField(array('name' => 'posted', 'label' => 'posted', 'type' => 'JxFieldHidden', 'size' => '11', 'required' => 'true', 'value' => time()));
 }
Exemplo n.º 5
0
 /**
  * create
  *
  * <b>IF YOU WANT PERMISSIONS TO WORK ON A ROW LEVEL YOU MUST USE THIS
  * FUNCTION!!!!!!</b> I can't stress this enough. This function will create
  * the content meta data and return a contentID for your child table's
  * record.
  *
  * @author Joe Stump <*****@*****.**>
  * @param string $title
  * @param int $userID
  * @param int $postTime
  * @return int
  */
 function create($options)
 {
     if (is_array($options) && count($options)) {
         $title = $options['title'];
         $search = $options['search'];
         $userID = $options['userID'] > 0 ? $options['userID'] : null;
         $postTime = $options['postTime'] > 0 ? $options['postTime'] : time();
         $module = strlen($options['module']) ? $options['module'] : null;
         $available = $options['available'] > 0 ? $options['available'] : 0;
     } else {
         return 0;
     }
     if (!strlen($title)) {
         return 0;
     }
     $content =& DB_DataObject::factory('content');
     $content->contentID = JxCreateId('content', 'contentID');
     $content->userID = $userID === null ? $this->user->userID : $userID;
     $content->posted = $postTime;
     $content->lastUpdate = 0;
     $content->available = $available;
     $content->mime = !strlen($this->mime) ? $this->table : $this->mime;
     $content->title = $title;
     $content->search = $search;
     $content->module = $module === null ? $this->table : $module;
     if ($content->insert()) {
         // DEFAULT PERMISSIONS FOR EACH NEW CONTENT!
         $default_groups_perms = array(JX_GRP_ADMIN => 700, JX_GRP_REG => 500, JX_GRP_ANON => 400);
         while (list($gid, $perms) = each($default_groups_perms)) {
             $groups =& DB_DataObject::factory('content_groups');
             if (!PEAR::isError($groups)) {
                 $groups->contentID = $content->contentID;
                 $groups->groupID = $gid;
                 $groups->permissions = $perms;
                 if (!$groups->insert()) {
                     return 0;
                 }
             }
         }
         $this->log->log('JxContent: ' . $content->contentID . ' created by ' . $this->user->email);
         return $content->contentID;
         // everything went well
     }
     return 0;
 }