Esempio n. 1
0
 /**
  * Create a unique identifier for a poll.
  * @param unknown_type $user
  * @return unknown_type
  */
 public static function createPollName($user)
 {
     $t = self::table(__CLASS__);
     if ($user === false) {
         $uid = 0;
         $uname = '_x_guest';
     } else {
         $uid = $user->getVar('user_id');
         $uname = '_y_' . $user->getVar('user_name');
     }
     if (false === ($name = $t->selectVar('vm_name', "vm_uid={$uid}", 'vm_date DESC'))) {
         $count = 1;
     } else {
         if (1 === preg_match('/^_(?:x|y)_.+_(\\d+)$/D', $name, $matches)) {
             $count = $matches[1] + 1;
         } else {
             $count = 1;
         }
     }
     //		$count = $t->countRows("vm_uid=$uid") + 1;
     return $uname . '_' . $count;
 }
Esempio n. 2
0
 /**
  * @param unknown_type $user
  * @param unknown_type $href
  * @param unknown_type $descr
  * @param unknown_type $descr2
  * @param unknown_type $tags
  * @param unknown_type $score
  * @param unknown_type $gid
  * @param unknown_type $sticky
  * @param unknown_type $in_moderation
  * @param unknown_type $unafiliate
  * @param unknown_type $memberlink
  * @return GWF_Links
  */
 public static function fakeLink($user, $href, $descr, $descr2, $tags = '', $score = 0, $gid = 0, $sticky = false, $in_moderation = false, $unafiliate = false, $memberlink = false, $private = false, $langid = 1)
 {
     $options = 0;
     $options |= $sticky ? self::STICKY : 0;
     $options |= $in_moderation ? self::IN_MODERATION : 0;
     $options |= $unafiliate ? self::UNAFILIATE : 0;
     $options |= $memberlink ? self::MEMBER_LINK : 0;
     $options |= $private ? self::ONLY_PRIVATE : 0;
     return new self(array('link_id' => 0, 'link_user' => $user, 'link_gid' => $gid, 'link_score' => $score, 'link_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'link_href' => $href, 'link_descr' => $descr, 'link_descr2' => $descr2, 'link_clicks' => 0, 'link_favcount' => 0, 'link_options' => $options, 'link_voteid' => 0, 'link_readby' => $user === false ? ':' : ':' . $user->getVar('user_id') . ':', 'link_tags' => $tags, 'link_popular' => 0, 'link_lang' => $langid));
 }
Esempio n. 3
0
 /**
  * Save a icms_view_block_Object Object
  *
  * Overwrited Method
  *
  * @param unknown_type $obj
  * @param unknown_type $force
  * @param unknown_type $checkObject
  * @param unknown_type $debug
  * @return unknown
  */
 public function insert(&$obj, $force = false, $checkObject = true, $debug = false)
 {
     $new = $obj->isNew();
     $obj->setVar('last_modified', time());
     $obj->setVar('isactive', true);
     if (!$new) {
         $sql = sprintf("DELETE FROM %s WHERE block_id = '%u'", $this->db->prefix('block_module_link'), (int) $obj->getVar('bid'));
         if (false != $force) {
             $this->db->queryF($sql);
         } else {
             $this->db->query($sql);
         }
     } else {
         icms_loadLanguageFile('system', 'blocksadmin', true);
         if ($obj->getVar('block_type') == 'K') {
             $obj->setVar('name', _AM_CLONE);
         } else {
             switch ($obj->getVar('c_type')) {
                 case 'H':
                     $obj->setVar('name', _AM_CUSTOMHTML);
                     break;
                 case 'P':
                     $obj->setVar('name', _AM_CUSTOMPHP);
                     break;
                 case 'S':
                     $obj->setVar('name', _AM_CUSTOMSMILE);
                     break;
                 case 'T':
                     $obj->setVar('name', _AM_CUSTOMNOSMILE);
                     break;
                 default:
                     break;
             }
         }
     }
     $status = parent::insert($obj, $force, $checkObject, $debug);
     // TODO: Make something to no query here... implement IPF for block_module_link
     $page = $obj->getVar('visiblein', 'e');
     if (!empty($page)) {
         if (is_array($obj->getVar('visiblein', 'e'))) {
             foreach ($obj->getVar('visiblein', 'e') as $bmid) {
                 $page = explode('-', $bmid);
                 $mid = $page[0];
                 $pageid = $page[1];
                 $sql = "INSERT INTO " . $this->db->prefix('block_module_link') . " (block_id, module_id, page_id) VALUES ('" . (int) $obj->getVar("bid") . "', '" . (int) $mid . "', '" . (int) $pageid . "')";
                 if (false != $force) {
                     $this->db->queryF($sql);
                 } else {
                     $this->db->query($sql);
                 }
             }
         } else {
             $page = explode('-', $obj->getVar('visiblein', 'e'));
             $mid = $page[0];
             $pageid = $page[1];
             $sql = "INSERT INTO " . $this->db->prefix('block_module_link') . " (block_id, module_id, page_id) VALUES ('" . (int) $obj->getVar("bid") . "', '" . (int) $mid . "', '" . (int) $pageid . "')";
             if (false != $force) {
                 $this->db->queryF($sql);
             } else {
                 $this->db->query($sql);
             }
         }
     }
     return $status;
 }
Esempio n. 4
0
 /**
  * Create a new thread that can be used as a fake thread.
  * You can also call insert() on it, and it becomes a real row.
  * @param unknown_type $user GWF_User or false
  * @param unknown_type $title string
  * @param unknown_type $boardid int
  * @param unknown_type $groupid int
  * @param unknown_type $postcount int
  * @param unknown_type $options int
  * @return GWF_ForumThread
  */
 public static function fakeThread($user = false, $title, $boardid = 0, $groupid = 0, $postcount = 1, $options = 0, $date = true)
 {
     if ($user === false) {
         $userid = 0;
         $username = '';
     } else {
         $userid = $user->getID();
         $username = $user->getVar('user_name');
     }
     $date = is_bool($date) ? GWF_Time::getDate(GWF_Date::LEN_SECOND) : $date;
     return new self(array('thread_tid' => 0, 'thread_bid' => $boardid, 'thread_gid' => $groupid, 'thread_uid' => $userid, 'thread_firstposter' => $username, 'thread_firstdate' => $date, 'thread_lastpost' => 0, 'thread_lastposter' => $username, 'thread_lastdate' => $date, 'thread_title' => $title, 'thread_options' => $options, 'thread_postcount' => $postcount, 'thread_viewcount' => 0, 'thread_watchers' => 0, 'thread_thanks' => 0, 'thread_votes_up' => 0, 'thread_votes_down' => 0, 'thread_unread' => $user === false ? ':' : ':' . $user->getID() . ':', 'thread_pollid' => 0, 'thread_force_unread' => ':'));
 }