Пример #1
0
 public function setUnrun_by_aid($aid, $r)
 {
     //设置允许运行,如果文件在本地同时修改实际文件名,增加无法运行的后缀;
     $data = parent::fetch($aid);
     if ($data['remote'] == 0 || $data['remote'] == 1) {
         //文件在本地,修改文件名
         if ($r > 0) {
             $earr = explode('.', $data['attachment']);
             foreach ($earr as $key => $ext) {
                 if (in_array(strtolower($ext), array($data['filetype'], 'dzz'))) {
                     unset($earr[$key]);
                 }
             }
             $tattachment = implode('.', $earr) . '.dzz';
             if ($is_file(getglobal('setting/attachdir') . './' . $data['attachment']) && @rename(getglobal('setting/attachdir') . './' . $data['attachment'], getglobal('setting/attachdir') . './' . $tattachment)) {
                 return parent::update($aid, array('unrun' => $r, 'attachment' => $tattachment));
             }
         } else {
             $earr = explode('.', $data['attachment']);
             foreach ($earr as $key => $ext) {
                 if (in_array(strtolower($ext), array($data['filetype'], 'dzz'))) {
                     unset($earr[$key]);
                 }
             }
             $tattachment = implode('.', $earr) . '.' . $data['filetype'];
             if ($is_file(getglobal('setting/attachdir') . './' . $data['attachment']) && @rename(getglobal('setting/attachdir') . './' . $data['attachment'], getglobal('setting/attachdir') . './' . $tattachment)) {
                 return parent::update($aid, array('unrun' => $r, 'attachment' => $tattachment));
             }
         }
     }
     return false;
 }
Пример #2
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;
 }
Пример #3
0
 public function update_by_cid($cid, $message, $rcid, $attach)
 {
     $ret = 0;
     $ret += parent::update($cid, array('message' => $message, 'rcid' => $rcid, 'edituid' => getglobal('uid'), 'edittime' => TIMESTAMP));
     $ret += C::t('comment_attach')->update_by_cid($cid, $attach);
     return $ret;
 }
Пример #4
0
 public function update($routerid, $setarr)
 {
     if ($setarr['router']) {
         $setarr['router'] = serialize($setarr['router']);
     }
     return parent::update($routerid, $setarr);
 }
Пример #5
0
 public function catmove_by_catid($catid, $up = 0)
 {
     //移动分类
     $cat = self::fetch($catid);
     $disparr = array();
     $i = 0;
     $cur = 0;
     foreach (self::fetch_all_by_pid($cat['pid']) as $value) {
         $disparr[] = $value;
         if ($value['catid'] == $catid) {
             $cur = $i;
         }
         $i++;
     }
     if ($up) {
         $disp = $disparr[$cur - 1 < 0 ? 0 : $cur - 1]['disp'] - 1;
     } else {
         $disp = $disparr[$cur + 1 > $i - 1 ? $i - 1 : $cur + 1]['disp'] + 1;
     }
     foreach ($disparr as $value) {
         if ($value['catid'] == $catid) {
             continue;
         }
         if (!$up) {
             if ($value['disp'] >= $disp) {
                 parent::update($value['catid'], array('disp' => $value['disp'] + 1));
             }
         } else {
             if ($value['disp'] <= $disp) {
                 parent::update($value['catid'], array('disp' => $value['disp'] - 1));
             }
         }
     }
     return parent::update($catid, array('disp' => $disp));
 }
Пример #6
0
 public function update_by_tpid($tpid, $setarr)
 {
     if (!($data = parent::fetch($tpid))) {
         return 0;
     }
     if (isset($setarr['body'])) {
         //含有body字段,处理附件
         $oaids = $data['attachs'] ? explode(',', $data['attachs']) : array();
         $attachs = self::getAidsByMessage($setarr['body']);
         $aids = $attachs ? implode(',', $attachs) : array();
         if ($oaids) {
             C::t('attachment')->addcopy_by_aid($oaids, -1);
         }
         if ($aids) {
             C::t('attachment')->addcopy_by_aid($aids);
         }
         $setting['attachs'] = $attachs ? implode(',', $attachs) : '';
     }
     return parent::update($tpid, $setarr);
 }
Пример #7
0
 public function update_count_by_cid($cid)
 {
     $arr = array();
     $arr['documents'] = DB::result_first("select COUNT(*) from %t where cid=%d and type='file' and deletetime<1 ", array('corpus_class', $cid));
     $arr['follows'] = DB::result_first("select COUNT(*) from %t where cid=%d and perm=1", array('corpus_user', $cid));
     $arr['members'] = DB::result_first("select COUNT(*) from %t where cid=%d and perm>1", array('corpus_user', $cid));
     parent::update($cid, $arr);
     return $arr;
 }
Пример #8
0
 public function update_by_voteid($voteid, $arr, $item, $itemnew)
 {
     C::t('vote_item')->update_by_voteid($voteid, $item, $itemnew);
     return parent::update($voteid, $arr);
 }
Пример #9
0
 public function delete_by_did($did, $force = false)
 {
     if (!($data = self::fetch($did))) {
         return false;
     }
     if ($force || $data['isdelete']) {
         //删除版本
         C::t('document_reversion')->delete_by_did($did);
         //删除评论
         C::t('comment')->delete_by_id_idtype($did, 'document');
         return parent::delete($did);
     } else {
         return parent::update($did, array('isdelete' => TIMESTAMP));
     }
 }
Пример #10
0
 public function wx_update($orgid)
 {
     global $_G;
     if (!$this->_wxbind) {
         return;
     }
     if (!($org = parent::fetch($orgid))) {
         return false;
     }
     $wx = new qyWechat(array('appid' => $_G['setting']['CorpID'], 'appsecret' => $_G['setting']['CorpSecret'], 'agentid' => 0));
     $wd = array();
     if ($wxdepart = $wx->getDepartment()) {
         foreach ($wxdepart['department'] as $value) {
             $wd[$value['id']] = $value;
         }
     } else {
         return false;
     }
     if ($org['forgid']) {
         if (($forg = parent::fetch($org['forgid'])) && !$forg['worgid']) {
             if ($worgid = self::wx_update($forg['orgid'])) {
                 $forg['worgid'] = $worgid;
             } else {
                 return;
             }
         }
     }
     $parentid = $org['forgid'] == 0 ? 1 : $forg['worgid'];
     if ($org['worgid'] && $wd[$org['worgid']] && $parentid == $wd[$org['worgid']]['parentid']) {
         //更新机构信息
         $data = array("id" => $org['worgid']);
         if ($wd[$org['worgid']]['name'] != $org['orgname']) {
             $data['name'] = $org['orgname'];
         }
         if ($wd[$org['worgid']]['parentid'] != $parentid) {
             $data['parentid'] = $parentid;
         }
         if ($wd[$org['worgid']]['order'] != $org['order']) {
             $data['order'] = $org['order'];
         }
         if ($data) {
             $data['id'] = $org['worgid'];
         }
         if ($data) {
             if (!$wx->updateDepartment($data)) {
                 $message = 'updateDepartment:errCode:' . $wx->errCode . ';errMsg:' . $wx->errMsg;
                 runlog('wxlog', $message);
                 return false;
             }
         }
         return $org['worgid'];
     } else {
         $data = array("name" => $org['orgname'], "parentid" => $org['forgid'] == 0 ? 1 : $forg['worgid'], "order" => $org['disp'] + 1);
         if ($ret = $wx->createDepartment($data)) {
             parent::update($orgid, array('worgid' => $ret['id']));
             return $ret['id'];
         } else {
             if ($wx->errCode == '60008') {
                 //部门的worgid不正确导致的问题
                 foreach ($wd as $value) {
                     if ($value['name'] == $data['name'] && ($value['parentid'] = $data['parentid'])) {
                         C::t('organization')->update($org['orgid'], array('worgid' => $value['id']));
                         return $value['id'];
                     }
                 }
             }
             $message = 'createDepartment:errCode:' . $wx->errCode . ';errMsg:' . $wx->errMsg;
             runlog('wxlog', $message);
             return false;
         }
     }
     return false;
 }
 public function delete_by_version($did, $version)
 {
     $vers = self::fetch_all_by_did($did);
     self::delete($vers[$version]['revid']);
     unset($vers[$version]);
     $vers1 = array();
     $vers = array_values(array_reverse($vers));
     foreach ($vers as $key => $value) {
         $value['version'] = $key + 1;
         parent::update($value['revid'], array('version' => $value['version']));
     }
     //更新主文档表
     if ($value['version'] > 0) {
         $setarr = array('version' => $value['version'], 'uid' => $new['uid'], 'username' => $value['username'], 'aid' => $value['aid']);
         C::t('document')->update($did, $setarr);
         return $value['version'];
     } else {
         return false;
     }
 }
Пример #12
0
 public function insert($uid, $ip, $groupid, $extdata, $adminid = 0)
 {
     if ($uid = dintval($uid)) {
         $profile = isset($extdata['profile']) ? $extdata['profile'] : array();
         //$profile['uid'] = $uid;
         $base = array('uid' => $uid, 'adminid' => intval($adminid), 'groupid' => intval($groupid), 'regdate' => TIMESTAMP, 'emailstatus' => intval($extdata['emailstatus']));
         $status = array('uid' => $uid, 'regip' => (string) $ip, 'lastip' => (string) $ip, 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP, 'lastsendmail' => 0);
         $ext = array('uid' => $uid);
         parent::update($uid, $base);
         C::t('user_status')->insert($status, false, true);
         C::t('user_profile1')->update($uid, $profile);
     }
 }
Пример #13
0
 public function update_by_newid($arr)
 {
     $data = parent::fetch($arr['newid']);
     if ($return = parent::update($arr['newid'], $arr)) {
         if ($data['attachs']) {
             $attachs = explode(',', $data['attachs']);
             C::t('attachment')->addcopy_by_aid($attachs, -1);
         }
         if (isset($arr['attachs'])) {
             $attachs = explode(',', $arr['attachs']);
             C::t('attachment')->addcopy_by_aid($attachs, 1);
         }
         //新添加的范围重新发送通知
         $orgids = $uids = array();
         if ($arr['orgids'] != $data['orgids']) {
             $norgids = $arr['orgids'] ? explode(',', $arr['orgids']) : array();
             $oorgids = $data['orgids'] ? explode(',', $data['orgids']) : array();
             $orgids = array_diff($norgids, $oorigids);
         }
         if ($arr['uids'] != $data['uids']) {
             $nuids = $arr['uids'] ? explode(',', $arr['uids']) : array();
             $ouids = $data['uids'] ? explode(',', $data['uids']) : array();
             $uids = array_diff($nuids, $ouids);
         }
         $new_uids = getUidsByOrgid($orgids, $uids);
         $appid = C::t('app_market')->fetch_appid_by_mod('{dzzscript}?mod=news', 0);
         foreach ($new_uids as $uid) {
             if ($uid != getglobal('uid')) {
                 //发送通知
                 $notevars = array('from_id' => $appid, 'from_idtype' => 'app', 'url' => DZZSCRIPT . '?mod=news&op=view&newid=' . $data['newid'], 'author' => getglobal('username'), 'authorid' => getglobal('uid'), 'subject' => $data['subject'], 'dataline' => dgmdate(TIMESTAMP));
                 $action = 'news_publish';
                 $type = 'news_publish_' . $uid;
                 dzz_notification::notification_add($uid, $type, $action, $notevars, 0, 'dzz/news');
             }
         }
     }
     return $return;
 }
Пример #14
0
 public function restore_by_fid($fid)
 {
     $fids = self::getParentByFid($fid);
     if ($fids && ($return = parent::update($fids, array('deletetime' => 0, 'deleteuid' => 0)))) {
         //产生事件
         foreach ($fids as $value) {
             $class = parent::fetch($value);
             $event = array('uid' => getglobal('uid'), 'username' => getglobal('username'), 'body_template' => 'corpus_restore_' . ($class['type'] == 'file' ? 'doc' : 'dir'), 'body_data' => serialize(array('cid' => $class['cid'], 'fid' => $class['fid'], 'fname' => $class['fname'])), 'dateline' => TIMESTAMP, 'bz' => 'corpus_' . $class['cid']);
             C::t('corpus_event')->insert($event);
         }
     }
     return $return;
 }
Пример #15
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;
 }
Пример #16
0
 public function change_perm_by_uid($cid, $uid, $perm)
 {
     //管理员必须留一人
     $data = DB::fetch_first("select * from %t where cid=%d and uid=%d", array($this->_table, $cid, $uid));
     if ($data['perm'] > 2 && $perm < 3 && DB::result_first("select COUNT(*) from %t where cid=%d and perm>2", array($this->_table, $cid)) < 2) {
         return array('error' => '至少需要一名管理员');
     }
     parent::update($data['id'], array('perm' => $perm, 'dateline' => TIMESTAMP));
     if ($data['perm'] != $perm) {
         //权限改变
         $permtitle = array('1' => '关注成员', '2' => '协作成员', '3' => '管理员');
         if ($uid != getglobal('uid')) {
             //发送通知
             $appid = C::t('app_market')->fetch_appid_by_mod('{dzzscript}?mod=corpus', 1);
             $corpus = C::t('corpus')->fetch($cid);
             $notevars = array('from_id' => $appid, 'from_idtype' => 'app', 'url' => DZZSCRIPT . '?mod=corpus&op=list&cid=' . $corpus['cid'] . '&do=user', 'author' => getglobal('username'), 'authorid' => getglobal('uid'), 'dataline' => dgmdate(TIMESTAMP), 'corpusname' => getstr($corpus['name'], 30), 'permtitle' => $permtitle[$perm]);
             $action = 'corpus_user_change';
             $type = 'corpus_user_change_' . $cid;
             dzz_notification::notification_add($uid, $type, $action, $notevars, 0, 'dzz/corpus');
         }
     }
     return true;
 }