Пример #1
0
 public function insert_by_tid_uid($tid, $uid)
 {
     if (!$tid || !$uid) {
         return false;
     }
     return parent::insert(array('tid' => $tid, 'uid' => $uid), 0, 1);
 }
Пример #2
0
 public function insert_by_exts($appid, $exts)
 {
     if (!$appid) {
         return false;
     }
     if (!is_array($exts)) {
         $exts = $exts ? explode(',', $exts) : array();
     }
     //删除原来的ext
     $oexts = array();
     $delids = array();
     $oextarr = DB::fetch_all("select * from " . DB::table('app_open') . " where appid='{$appid}'");
     foreach ($oextarr as $value) {
         $oexts[] = $value['ext'];
         if (!in_array($value['ext'], $exts)) {
             $delids[] = $value['extid'];
         }
     }
     if ($delids) {
         self::delete($delids);
     }
     foreach ($exts as $ext) {
         if ($ext && !in_array($ext, $oexts)) {
             parent::insert(array('ext' => $ext, 'appid' => $appid));
         }
     }
     $this->clear_cache('ext_all');
     $this->clear_cache('all');
     return true;
 }
Пример #3
0
 public function insert_by_sid($arr)
 {
     $arr['uid'] = getglobal('uid');
     $arr['username'] = getglobal('username');
     $arr['status'] = 0;
     if (empty($arr['path'])) {
         return false;
     }
     $sid = self::getSid($arr['path'] . '&uid=' . getglobal('uid'));
     if (DB::result_first("select COUNT(*) from %t where sid=%s", array($this->_table, $sid))) {
         parent::update($sid, $arr);
         if (!is_file(getglobal('setting/attachurl') . './qrcode/' . $sid[0] . '/' . $sid . '.png')) {
             self::getQRcodeBySid($sid);
         }
         return array('sid' => $sid, 'shareurl' => getglobal('siteurl') . 's.php?sid=' . $sid, 'qrcode' => getglobal('setting/attachurl') . './qrcode/' . $sid[0] . '/' . $sid . '.png');
     } else {
         $arr['sid'] = $sid;
         $arr['dateline'] = TIMESTAMP;
         if (parent::insert($arr, 1, 1)) {
             self::getQRcodeBySid($sid);
             return array('sid' => $sid, 'shareurl' => getglobal('siteurl') . 's.php?sid=' . $sid, 'qrcode' => getglobal('setting/attachurl') . './qrcode/' . $sid[0] . '/' . $sid . '.png');
         }
     }
     return false;
 }
Пример #4
0
 public function insert_by_voteid($arr, $itemnew)
 {
     if ($voteid = parent::insert($arr, 1)) {
         C::t('vote_item')->update_by_voteid($voteid, array(), $itemnew);
     }
     return $voteid;
 }
Пример #5
0
 public function copy_by_cid($ocid, $cid)
 {
     foreach (DB::fetch_all("select * from %t where cid=%d", array($this->_table, $ocid)) as $value) {
         $value['cid'] = $cid;
         parent::insert($value, 0, 1);
     }
     return 0;
 }
Пример #6
0
 public function insert($cachename, $data)
 {
     parent::insert(array('cname' => $cachename, 'ctype' => is_array($data) ? 1 : 0, 'dateline' => TIMESTAMP, 'data' => is_array($data) ? serialize($data) : $data), false, true);
     if ($this->_allowmem && memory('get', $cachename) !== false) {
         memory('set', $cachename, $data);
     }
     $this->_isfilecache && @unlink(DZZ_ROOT . './data/cache/cache_' . $cachename . '.php');
 }
 public function insert_by_uid($uid, $jobid)
 {
     if (!$jobid) {
         return self::delete_by_uid($uid);
     }
     $setarr = array('uid' => $uid, 'jobid' => $jobid, 'dateline' => TIMESTAMP, 'opuid' => getglobal('uid'));
     return parent::insert($setarr, 1, 1);
 }
Пример #8
0
 public function insert($setarr)
 {
     if ($fid = parent::insert($setarr, 1)) {
         //产生事件
         $event = array('uid' => getglobal('uid'), 'username' => getglobal('username'), 'body_template' => 'corpus_create_' . ($setarr['type'] == 'file' ? 'doc' : 'dir'), 'body_data' => serialize(array('cid' => $setarr['cid'], 'fid' => $fid, 'fname' => $setarr['fname'])), 'dateline' => TIMESTAMP, 'bz' => 'corpus_' . $setarr['cid']);
         C::t('corpus_event')->insert($event);
     }
     return $fid;
 }
Пример #9
0
 public function insert_by_itemid($itemids, $uid)
 {
     $itemids = (array) $itemids;
     $ret = 0;
     foreach ($itemids as $itemid) {
         $ret += parent::insert(array('uid' => $uid, 'itemid' => $itemid, 'dateline' => TIMESTAMP), 0, 1);
     }
     return $ret;
 }
Пример #10
0
 public function insert_by_pid($pid, $tid, $uids)
 {
     if (!$pid || !$uids) {
         return false;
     }
     foreach ($uids as $uid) {
         parent::insert(array('pid' => $pid, 'tid' => $tid, 'uid' => $uid, 'dateline' => TIMESTAMP), 0, 1);
     }
 }
 public function insert($uid, $orgid)
 {
     if (!$uid || !$orgid) {
         return 0;
     }
     $id = parent::insert(array("orgid" => $orgid, 'uid' => $uid, 'opuid' => getglobal('uid'), 'dateline' => TIMESTAMP), 1, 1);
     self::update_groupid_by_uid($uid);
     return DB::result_first('select id from %t where uid=%d and orgid=%d', array($this->_table, $uid, $orgid));
 }
Пример #12
0
 public function update_lasttime($uid, $appid, $lasttime)
 {
     if (!$uid) {
         return false;
     }
     if (DB::query("update " . DB::table($this->_table) . " set lasttime=" . intval($lasttime) . ", num=num+1 where appid='{$appid}' and uid='{$uid}'")) {
     } else {
         parent::insert(array('uid' => $uid, 'appid' => $appid, 'lasttime' => $lasttime, 'dateline' => TIMESTAMP, 'num' => 1), false, true);
     }
 }
Пример #13
0
 public function insert($arr)
 {
     $ret = 0;
     if ($ret = parent::insert($arr, 1)) {
         if ($arr['aid']) {
             C::t('attachment')->addcopy_by_aid($arr['aid'], 1);
         }
     }
     return $ret;
 }
Пример #14
0
 public function getShortUrl($url)
 {
     $sid = self::getSid($url);
     if (DB::result_first("select COUNT(*) from %t where sid=%s", array($this->_table, $sid))) {
         return getglobal('siteurl') . 'short.php?sid=' . $sid;
     }
     $setarr = array('sid' => $sid, 'url' => $url);
     if (parent::insert($setarr)) {
         return getglobal('siteurl') . 'short.php?sid=' . $sid;
     }
     return '';
 }
Пример #15
0
 public function insert($arr, $attachs = array(), $area = '', $areaid = 0, $new = 0)
 {
     //插入
     if (!$arr['did']) {
         //首次插入
         $setarr = $arr;
         $setarr['version'] = 1;
         $setarr['area'] = $area;
         $setarr['areaid'] = $areaid;
         $setarr['dateline'] = TIMESTAMP;
         $arr['did'] = parent::insert($setarr, 1);
     }
     $arr['attachs'] = $attachs;
     //插入版本库
     $verarr = array('did' => $arr['did'], 'aid' => $arr['aid'], 'uid' => $arr['uid'], 'username' => $arr['username'], 'attachs' => $attachs);
     if ($re = C::t('document_reversion')->insert($verarr, $new)) {
         $setarr = array('version' => $re['version'], 'uid' => $arr['uid'], 'username' => $arr['username'], 'aid' => $arr['aid']);
         parent::update($re['did'], $setarr);
     }
     return $arr['did'];
 }
Пример #16
0
 public function copy_by_cid($ocid, $cid)
 {
     $aids = array();
     foreach (DB::fetch_all("select * from %t where cid=%d", array($this->_table, $ocid)) as $value) {
         unset($value['qid']);
         $value['cid'] = $cid;
         if (parent::insert($value)) {
             if ($value['type'] == 'attach' && $value['aid'] > 0) {
                 C::t('attachment')->addcopy_by_aid($value['aid']);
             }
             if ($value['type'] == 'link') {
                 $imgarr = $value['img'] ? explode('icon', $value['img']) : array();
                 if (isset($imgarr[1]) && ($did = DB::result_first("select did from %t where pic=%s", array('icon', 'icon' . $imgarr[1])))) {
                     C::t('icon')->update_copys_by_did($did);
                 }
             }
         }
     }
     return 0;
 }
Пример #17
0
 public function insert_by_catid($setarr)
 {
     $setarr['disp'] = DB::result_first("select max(disp) from %t where pid=%d", array($this->_table, $setarr['pid'])) + 1;
     return parent::insert($setarr, 1);
 }
 public function insert($data, $return_insert_id = false, $replace = false, $silent = false)
 {
     $this->clear_cache('fields_0');
     $this->clear_cache('fields_1');
     return parent::insert($data, $return_insert_id, $replace, $silent);
 }
Пример #19
0
 public function move_to_forgid_by_orgid($forgid, $orgid)
 {
     //移动用户到上级部门
     if (!($org = C::t('organization')->fetch($forgid))) {
         return false;
     }
     if (!$org['forgid']) {
         return self::delete_by_orgid($orgid);
     }
     foreach (DB::fetch_all("select * from %t where orgid=%d", array($this->_table, $orgid)) as $value) {
         if (DB::result_first("select COUNT(*) from %t where orgid=%d and uid=%d", array($this->_table, $org['forgid'], $value['uid']))) {
             DB::delete($this->_table, "orgid='{$org[forgid]}' and uid='{$value[uid]}'");
         } else {
             $value['orgid'] = $org['forgid'];
             parent::insert($value);
         }
     }
     return true;
 }
Пример #20
0
 public function insert($setarr)
 {
     $setarr['router'] = serialize($setarr['router']);
     return parent::insert($setarr, 1);
 }
Пример #21
0
 public function insert_by_forgid($setarr, $borgid)
 {
     if ($borgid) {
         $setarr['disp'] = self::getDispByOrgid($borgid);
     }
     if ($setarr['orgid'] = parent::insert($setarr, true)) {
         //self::setFolderByOrgid($org['orgid']);
         //include_once libfile('function/cache');
         //updatecache('organization');
         if ($this->_wxbind) {
             //同步到微信端
             self::wx_update($setarr['orgid']);
         }
         self::setPathkeyByOrgid($setarr['orgid']);
         return $setarr;
     }
     return false;
 }
Пример #22
0
 public function update_by_voteid($voteid, $item, $itemnew)
 {
     if (!($vote = C::t('vote')->fetch($voteid))) {
         return false;
     }
     //删除已有的项目
     $sql = 'voteid=%d';
     $param = array($this->_table, $voteid);
     if ($item && ($ids = array_keys($item))) {
         $sql .= " and itemid NOT IN(%n)";
         $param[] = $ids;
     }
     $dels = array();
     foreach (DB::fetch_all("select itemid,aid from %t where {$sql}", $param) as $value) {
         if ($value['aid']) {
             C::t('attachment')->delete_by_aid($value['aid']);
         }
         $dels[] = $value['itemid'];
     }
     if (parent::delete($dels)) {
         C::t('vote_item_count')->delete_by_itemid($dels);
     }
     //更新已有项目
     $addcopyaids = array();
     foreach ($item as $key => $value) {
         if (empty($value['content']) && !$value['aid']) {
             self::delete_by_itemid($key);
         }
         $value['content'] = getstr($value['content']);
         parent::update($key, $value);
     }
     //添加新项目
     $disp = DB::result_first("select max(disp) from %t where voteid=%d", array($this->_table, $voteid));
     foreach ($itemnew as $key => $value) {
         if (empty($value['content']) && !$value['aid']) {
             continue;
         }
         $disp++;
         $setarr = array('voteid' => $voteid, 'content' => getstr($value['content']), 'type' => $value['aid'] ? 2 : 1, 'aid' => intval($value['aid']), 'disp' => $disp, 'number' => 0);
         if (parent::insert($setarr, 1) && $setarr['aid']) {
             C::t('attachment')->addcopy_by_aid($setarr['aid']);
         }
     }
     return true;
 }
 public function insert($arr, $new)
 {
     //先获取最新版本,没有的话新插入
     $newest = array();
     if ($newest = DB::fetch_first("select * from %t where did=%d order by version DESC limit 1", array($this->_table, $arr['did']))) {
         if ($new) {
             $arr['version'] = $newest['version'] + 1;
             $arr['dateline'] = TIMESTAMP;
             $attachs = array();
             if ($arr['attachs']) {
                 $attachs = $arr['attachs'];
                 $arr['attachs'] = implode(',', $attachs);
             } else {
                 $arr['attachs'] = '';
             }
             if ($arr['revid'] = parent::insert($arr, 1)) {
                 $attachs[] = $arr['aid'];
                 C::t('attachment')->addcopy_by_aid($attachs);
                 //插入事件
                 $event = array('did' => $arr['did'], 'action' => 'edit', 'uid' => $arr['uid'], 'username' => $arr['username'], 'dateline' => TIMESTAMP);
                 C::t('document_event')->insert($event);
             }
         } else {
             $oldattachs = $newest['attachs'] ? explode(',', $newest['attachs']) : array();
             $oldattachs[] = $newest['aid'];
             $attachs = array();
             if ($arr['attachs']) {
                 $attachs = $arr['attachs'];
                 $arr['attachs'] = implode(',', $arr['attachs']);
             } else {
                 $arr['attachs'] = '';
             }
             $attachs[] = $arr['aid'];
             if (parent::update($newest['revid'], $arr)) {
                 $arr['version'] = $newest['version'];
                 $arr['revid'] = $newest['revid'];
                 $delaids = array_diff($oldattachs, $attachs);
                 C::t('attachment')->addcopy_by_aid($delaids, -1);
                 $insertaids = array_diff($attachs, $oldattachs);
                 C::t('attachment')->addcopy_by_aid($insertaids);
             }
         }
     } else {
         $arr['version'] = 1;
         $arr['dateline'] = TIMESTAMP;
         $attachs = array();
         if ($arr['attachs']) {
             $attachs = $arr['attachs'];
             $arr['attachs'] = implode(',', $arr['attachs']);
         } else {
             $arr['attachs'] = '';
         }
         if ($arr['revid'] = parent::insert($arr, 1)) {
             $attachs[] = $arr['aid'];
             C::t('attachment')->addcopy_by_aid($attachs);
             //插入事件
             $event = array('did' => $arr['did'], 'action' => 'create', 'uid' => $arr['uid'], 'username' => $arr['username'], 'dateline' => TIMESTAMP);
             C::t('document_event')->insert($event);
         }
     }
     if ($arr['revid']) {
         return $arr;
     } else {
         return false;
     }
 }
Пример #24
0
 public function insert_by_tpid($setarr)
 {
     $attachs = self::getAidsByMessage($setarr['body']);
     $setting['attachs'] = $attachs ? implode(',', $attachs) : '';
     return parent::insert($setarr, 1);
 }
Пример #25
0
 public function insert($arr)
 {
     return parent::insert($arr, 1, 1);
 }
Пример #26
0
 public function insert_by_newid($arr)
 {
     if ($newid = parent::insert($arr, 1)) {
         if ($arr['attachs']) {
             $attachs = explode(',', $arr['attachs']);
             C::t('attachment')->addcopy_by_aid($attachs, 1);
         }
         if ($arr['status'] == 2) {
             //需要审核时,发送通知给管理员;
             if (!getglobal('cache/news:setting')) {
                 loadcache('news:setting');
             }
             $setting = getglobal('cache/news:setting');
             if ($setting['moderators']) {
                 //通知发布者审核情况
                 $appid = C::t('app_market')->fetch_appid_by_mod('{dzzscript}?mod=news', 1);
                 foreach ($setting['moderators'] as $uid) {
                     if ($uid != getglobal('uid')) {
                         //发送通知
                         $notevars = array('from_id' => $appid, 'from_idtype' => 'app', 'url' => DZZSCRIPT . '?mod=news&status=2', 'author' => getglobal('username'), 'authorid' => getglobal('uid'), 'dataline' => dgmdate(TIMESTAMP));
                         $action = 'news_moderate';
                         $type = 'news_moderate';
                         dzz_notification::notification_add($uid, $type, $action, $notevars, 0, 'dzz/news');
                     }
                 }
             }
         } elseif ($arr['status'] == 1) {
             //通知发布范围内人员查看
             $uids = getUidsByOrgid($arr['orgids'], $arr['uids']);
             $appid = C::t('app_market')->fetch_appid_by_mod('{dzzscript}?mod=news', 0);
             foreach ($uids as $uid) {
                 if ($uid != getglobal('uid')) {
                     //发送通知
                     $notevars = array('from_id' => $appid, 'from_idtype' => 'app', 'url' => DZZSCRIPT . '?mod=news&op=view&newid=' . $newid, 'author' => getglobal('username'), 'authorid' => getglobal('uid'), 'subject' => $arr['subject'], 'dataline' => dgmdate(TIMESTAMP));
                     $action = 'news_publish';
                     $type = 'news_publish_' . $uid;
                     dzz_notification::notification_add($uid, $type, $action, $notevars, 0, 'dzz/news');
                 }
             }
         }
         return $newid;
     }
     return false;
 }
Пример #27
0
 public function copy_by_id_idtype($oid, $id, $idtype)
 {
     $return = 0;
     foreach (DB::fetch_all("select * from %t where id=%d and idtype=%s and pcid='0'", array($this->_table, $oid, $idtype)) as $value) {
         $ocid = $value['cid'];
         unset($value['cid']);
         $value['id'] = $id;
         if ($value['cid'] = parent::insert($value, 1)) {
             C::t('comment_at')->copy_by_cid($ocid, $value['cid']);
             C::t('comment_attach')->copy_by_cid($ocid, $value['cid']);
             $return += 1;
             //拷贝子评论
             foreach (DB::fetch_all("select * from %t where pcid=%d ", array($this->_table, $ocid)) as $value1) {
                 $ocid = $value1['cid'];
                 unset($value1['cid']);
                 $value1['pcid'] = $value['cid'];
                 $value1['id'] = $id;
                 $value1['rcid'] = 0;
                 if (parent::insert($value1, 1)) {
                     C::t('comment_at')->copy_by_cid($ocid, $value['cid']);
                     C::t('comment_attach')->copy_by_cid($ocid, $value['cid']);
                 }
             }
         }
     }
     return $return;
 }
Пример #28
0
 public function insert_by_cid($arr)
 {
     if ($cid = parent::insert($arr, 1)) {
         C::t('attachment')->addcopy_by_aid($arr['aid']);
         //封面copys+1
         C::t('corpus_class')->insert_default_by_cid($cid);
         //创建默认分类
         $userarr = array('uid' => $arr['uid'], 'username' => $arr['username'], 'perm' => 3, 'dateline' => TIMESTAMP, 'cid' => $cid);
         C::t('corpus_user')->insert($userarr);
         //创建用户
         //产生事件
         $event = array('uid' => getglobal('uid'), 'username' => getglobal('username'), 'body_template' => 'corpus_create', 'body_data' => serialize(array('cid' => $cid, 'corpusname' => $arr['name'])), 'dateline' => TIMESTAMP, 'bz' => 'corpus_' . $arr['cid']);
         C::t('corpus_event')->insert($event);
     }
     return $cid;
 }
Пример #29
0
 public function update_by_pid($pid, $tid, $attach)
 {
     $qids = array();
     $ret = 0;
     foreach (DB::fetch_all("select qid from %t where pid=%d", array($this->_table, $pid)) as $value) {
         $qids[$value['qid']] = $value['qid'];
     }
     foreach ($attach['title'] as $key => $value) {
         $qid = intval($attach['qid'][$key]);
         if ($qid > 0) {
             unset($qids[$qid]);
         } else {
             $setarr = array('pid' => $pid, 'tid' => $tid, 'dateline' => TIMESTAMP, 'aid' => intval($attach['aid'][$key]), 'title' => trim($value), 'type' => trim($attach['type'][$key]), 'img' => trim($attach['img'][$key]), 'url' => trim($attach['url'][$key]));
             if ($ret += parent::insert($setarr)) {
                 if ($setarr['aid']) {
                     C::t('attachment')->addcopy_by_aid($setarr['aid']);
                 }
                 if ($setarr['type'] == 'link') {
                     $imgarr = $setarr['img'] ? explode('icon', $setarr['img']) : array();
                     if (isset($imgarr[1]) && ($did = DB::result_first("select did from %t where pic=%s", array('icon', 'icon' . $imgarr[1])))) {
                         C::t('icon')->update_copys_by_did($did);
                     }
                 }
             }
         }
     }
     if ($qids) {
         $ret += self::delete_by_qid($qids);
     }
     return $ret;
 }