Esempio n. 1
0
 public function deleteAttachment(Attachments $attachment)
 {
     /** @var myModel $this */
     $attachment->delete();
     $this->decreaseCount('attachmentCount');
     return $this;
 }
Esempio n. 2
0
 private function getAttachment()
 {
     // FIXME: Do we really need to mess with memory limits here? We're only reading ~80KB at a time...
     @ini_set('memory_limit', '128M');
     if (!$this->isRequiredIDValid('id', $_GET)) {
         CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'No attachment ID specified.');
     }
     $attachmentID = $_GET['id'];
     $attachments = new Attachments(-1);
     $rs = $attachments->get($attachmentID, false);
     if (empty($rs) || md5($rs['directoryName']) != $_GET['directoryNameHash']) {
         CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid id / directory / filename, or you do not have permission to access this attachment.');
     }
     $directoryName = $rs['directoryName'];
     $fileName = $rs['storedFilename'];
     $filePath = sprintf('attachments/%s/%s', $directoryName, $fileName);
     /* Check for the existence of the backup.  If it is gone, send the user to a page informing them to press back and generate the backup again. */
     if ($rs['contentType'] == 'catsbackup' && !file_exists($filePath)) {
         CommonErrors::fatal(COMMONERROR_FILENOTFOUND, $this, 'The specified backup file no longer exists. Please go back and regenerate the backup before downloading. We are sorry for the inconvenience.');
     }
     // FIXME: Stream file rather than redirect? (depends on download preparer working).
     if (!eval(Hooks::get('ATTACHMENT_RETRIEVAL'))) {
         return;
     }
     /* Determine MIME content type of the file. */
     $contentType = Attachments::fileMimeType($fileName);
     /* Open the file and verify that it is readable. */
     $fp = @fopen($filePath, 'r');
     if ($fp === false) {
         CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'This attachment is momentarily offline, please try again later. The support staff has been notified.');
     }
     /* Set headers for sending the file. */
     header('Content-Disposition: inline; filename="' . $fileName . '"');
     //Disposition attachment was default, but forces download.
     header('Content-Type: ' . $contentType);
     header('Content-Length: ' . filesize($filePath));
     header('Pragma: no-cache');
     header('Expires: 0');
     /* Read the file in ATTACHMENT_BLOCK_SIZE-sized chunks from disk and
      * output to the browser.
      */
     while (!feof($fp)) {
         print fread($fp, self::ATTACHMENT_BLOCK_SIZE);
     }
     fclose($fp);
     /* Exit to prevent output after the attachment. */
     exit;
 }
Esempio n. 3
0
 function getInstance()
 {
     if (!isset(self::$instance[get_class()])) {
         self::$instance = new Attachments();
     }
     return self::$instance;
 }
Esempio n. 4
0
 public function actionIndex()
 {
     $tagid = zmf::val('tagid', 2);
     $tagInfo = array();
     $default = true;
     if ($tagid) {
         $tagInfo = Tags::getByIds($tagid);
         if ($tagInfo) {
             $default = false;
             $tagInfo = $tagInfo[0];
             $sql = "SELECT p.id,p.uid,p.title,p.faceimg,p.content,p.tagids,p.comments,p.favorite FROM {{posts}} p,{{tag_relation}} tr WHERE tr.tagid='{$tagid}' AND tr.classify='posts' AND tr.logid=p.id AND p.`status`=" . Posts::STATUS_PASSED . " ORDER BY p.cTime DESC";
         }
     }
     if ($default) {
         $sql = 'SELECT id,uid,title,faceimg,content,tagids,comments,favorite FROM {{posts}} WHERE `status`=1 ORDER BY cTime DESC';
     }
     Posts::getAll(array('sql' => $sql), $pages, $posts);
     $size = '640';
     if ($this->isMobile) {
         $size = '240';
     }
     foreach ($posts as $k => $val) {
         if ($val['tagids'] != '') {
             $_tags = Tags::getByIds($val['tagids']);
             $posts[$k]['tagids'] = $_tags;
         }
         $posts[$k]['faceimg'] = Attachments::faceImg($val, $size);
     }
     $this->pageTitle = '文章 - ' . zmf::config('sitename');
     $this->selectNav = 'posts';
     $data = array('posts' => $posts, 'tagInfo' => $tagInfo, 'pages' => $pages);
     $this->render('/index/index', $data);
 }
Esempio n. 5
0
 public function actionIndex()
 {
     if ($this->mySelf == 'yes') {
         $sql = "SELECT id,title,faceimg,uid,colid,cTime,updateTime FROM {{posts}} WHERE (uid='{$this->uid}' OR uid IN(SELECT logid FROM {{favorites}} WHERE uid='{$this->uid}' AND classify='user')) AND classify='" . Posts::CLASSIFY_WEDDING . "' ORDER BY cTime DESC";
     } else {
         $sql = "SELECT id,title,faceimg,uid,colid,cTime,updateTime FROM {{posts}} WHERE uid='{$this->uid}' AND classify='" . Posts::CLASSIFY_WEDDING . "' ORDER BY cTime DESC";
     }
     Posts::getAll(array('sql' => $sql), $pages, $lists);
     if (!empty($lists)) {
         foreach ($lists as $k => $p) {
             if ($p['faceimg'] > 0) {
                 $_attach = Attachments::getOne($p['faceimg']);
                 $_url = Attachments::getUrl($_attach);
                 $lists[$k]['faceimg'] = $_url;
             } else {
                 $lists[$k]['faceimg'] = '';
             }
         }
     }
     if ($this->mySelf != 'yes') {
         Posts::updateCount($this->uid, 'Users');
     }
     $data = array('posts' => $lists, 'pages' => $pages);
     $this->pageTitle = $this->userInfo['truename'] . '的主页 - ' . zmf::config('sitename');
     $this->render('index', $data);
 }
Esempio n. 6
0
 /**
  * 根据图片ID返回图片信息
  * @param type $id
  * @return boolean
  */
 public static function getOne($id)
 {
     if (!$id || !is_numeric($id)) {
         return false;
     }
     //todo,图片分表,将图片表分为attachments0~9
     return Attachments::model()->findByPk($id);
 }
Esempio n. 7
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Attachments the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Attachments::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 8
0
 public function executeUpload(sfWebRequest $request)
 {
     $file = $request->getFiles();
     $filename = mt_rand(111111, 999999) . '-' . $file['Filedata']['name'];
     if (move_uploaded_file($file['Filedata']['tmp_name'], sfConfig::get('sf_upload_dir') . '/attachments/' . $filename)) {
         $bind_id = $request->getParameter('bind_id');
         if ((int) $bind_id == 0) {
             $bind_id = -$this->getUser()->getAttribute('id');
         }
         $a = new Attachments();
         $a->setFile($filename);
         $a->setBindType($request->getParameter('bind_type'));
         $a->setBindId($bind_id);
         $a->save();
     }
     exit;
 }
Esempio n. 9
0
 public function actionStat()
 {
     $posts = Posts::model()->count();
     $commentsNum = Comments::model()->count();
     $attachsNum = Attachments::model()->count();
     $feedbackNum = Feedback::model()->count();
     $arr = array('posts' => $posts, 'commentsNum' => $commentsNum, 'attachsNum' => $attachsNum, 'feedbackNum' => $feedbackNum);
     $this->render('stat', $arr);
 }
Esempio n. 10
0
 public static function getAvatar($aid, $size = 170)
 {
     $info = Attachments::getOne($aid);
     $url = '';
     if ($info) {
         $url = zmf::uploadDirs($info['cTime'], 'site', $info['classify'], $size) . $info['filePath'];
     }
     return $url;
 }
Esempio n. 11
0
 public function executeAttachments()
 {
     Attachments::clearTmpUploadedFiles($this->getUser());
     $q = Doctrine_Core::getTable('Attachments')->createQuery()->addWhere('bind_id=?', $this->bind_id)->addWhere('bind_type=?', $this->bind_type)->orderBy('id');
     if ($this->bind_id > 0) {
         $q->addWhere("bind_id='" . $this->bind_id . "' or (bind_id='-" . $this->getUser()->getAttribute('id') . "')");
     } else {
         $q->addWhere("bind_id='-" . $this->getUser()->getAttribute('id') . "'");
     }
     $this->attachments = $q->execute();
 }
 /**
  * Constructor
  *
  * @param Request $request
  * @return AttachmentsController
  */
 function __construct($request)
 {
     parent::__construct($request);
     $attachment_id = $this->request->getId('attachment_id');
     if ($attachment_id) {
         $this->active_attachment = Attachments::findById($attachment_id);
     }
     // if
     if (!instance_of($this->active_attachment, 'Attachment')) {
         $this->active_attachment = new Attachment();
     }
     // if
     $this->smarty->assign(array('active_attachment' => $this->active_attachment));
 }
Esempio n. 13
0
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'cTime DESC';
     $count = Attachments::model()->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = 30;
     $pager->applyLimit($criteria);
     $posts = Attachments::model()->findAll($criteria);
     foreach ($posts as $k => $val) {
         $_img = Attachments::getUrl($val, 240);
         $posts[$k]['filePath'] = $_img;
     }
     $this->render('index', array('pages' => $pager, 'posts' => $posts));
 }
Esempio n. 14
0
 public function createZipFile(array $file_Ids, $filename)
 {
     $files = Attachments::query()->inWhere('attachable_id', $file_Ids)->andWhere('attachable_type =:type:', ['type' => 'Files'])->leftJoin('Files', 'file.id = Attachments.attachable_id', 'file')->columns(['Attachments.*', 'file.*'])->execute();
     $path = 'E:\\php\\standard\\public/';
     $zip = new ZipArchive();
     if ($zip->open($path . $filename, ZIPARCHIVE::CREATE) !== TRUE) {
         dd('无法生成ZIP文件,请检查是否具有写权限');
     }
     foreach ($files as $row) {
         $zip->addFile($path . $row->attachments->url, $row->file->title . '/' . $row->attachments->name);
         $zip->addFromString($row->file->title . '/info.txt', $this->getFileInfo($row->file));
         //@todo 将来用能够代表文档的数据形式来替代
     }
     $zip->close();
     return $filename;
 }
 /**
  * Creates a new AttachmentsEditor object.
  * 
  * @param	integer		$messageID
  * @param	string		$isHash
  * @param	string		$messageType
  * @param	integer		$maxFileSize
  * @param	string		$allowedExtensions
  * @param	integer		$maxUploads
  */
 public function __construct($messageID = 0, $messageType = 'post', $maxFileSize = 2000000, $allowedExtensions = "gif\njpg\njpeg\npng\nbmp\nzip\ntxt", $maxUploads = 5, $packageID = PACKAGE_ID, $thumbnailWidth = ATTACHMENT_THUMBNAIL_WIDTH, $thumbnailHeight = ATTACHMENT_THUMBNAIL_HEIGHT, $addSourceInfo = ATTACHMENT_THUMBNAIL_ADD_SOURCE_INFO, $useEmbedded = ATTACHMENT_THUMBNAIL_USE_EMBEDDED)
 {
     $this->messageID = $messageID;
     $this->thumbnailWidth = $thumbnailWidth;
     $this->thumbnailHeight = $thumbnailHeight;
     $this->addSourceInfo = $addSourceInfo;
     $this->useEmbedded = $useEmbedded;
     if (empty($this->messageID)) {
         $this->getIDHash();
     }
     // call parent constructor
     parent::__construct($messageID ? $messageID : null, $messageType, $this->idHash, $packageID);
     $this->maxFileSize = $maxFileSize;
     $this->maxUploads = $maxUploads;
     $allowedExtensions = StringUtil::unifyNewlines($allowedExtensions);
     $allowedExtensions = implode("\n", array_unique(explode("\n", $allowedExtensions)));
     $this->allowedExtensions = '/^(' . StringUtil::replace("\n", "|", StringUtil::replace('\\*', '.*', preg_quote($allowedExtensions, '/'))) . ')$/i';
     $this->allowedExtensionsDesc = self::formatAllowedExtensions($allowedExtensions);
     $this->getAttachmentHashes();
     $this->assign();
 }
Esempio n. 16
0
 public function doUserLogin($user, $request)
 {
     $this->getUser()->setAttribute('id', $user->getId());
     $this->getUser()->setAttribute('users_group_id', $user->getUsersGroupId());
     $this->getUser()->setAttribute('user', $user);
     $this->getUser()->setAuthenticated(true);
     Attachments::clearTmpUploadedFiles($this->getUser());
     $this->getUser()->setCulture($user->getCulture());
     if (strlen($user->getSkin()) > 0) {
         $this->getResponse()->setCookie('skin', $user->getSkin(), time() + 31536000, '', '');
     }
     $ug = $user->getUsersGroups();
     if ($ug->getAllowManageProjects() > 0) {
         $this->getUser()->addCredential('reports_access_projects');
     }
     if ($ug->getAllowManageTasks() > 0) {
         $this->getUser()->addCredential('reports_access_tasks');
         $this->getUser()->addCredential('reports_access_time');
         $this->getUser()->addCredential('reports_access_time_personal');
         $this->getUser()->addCredential('reports_access_gantt');
     }
     if ($ug->getAllowManageTickets() > 0) {
         $this->getUser()->addCredential('reports_access_tickets');
     }
     if ($ug->getAllowManageDiscussions() > 0) {
         $this->getUser()->addCredential('reports_access_discussions');
     }
     if ($ug->getAllowManageUsers() == 1) {
         $this->getUser()->addCredential('allow_manage_users');
     }
     if ($ug->getAllowManageConfiguration() == 1) {
         $this->getUser()->addCredential('allow_manage_configuration');
     }
     $this->getUser()->addCredential('allow_manage_personal_scheduler');
     if (strlen($request->getParameter('http_referer')) > 0) {
         $this->redirect($request->getParameter('http_referer'));
     } else {
         $this->redirect('dashboard/index');
     }
 }
Esempio n. 17
0
 public function actionCreate($id = '')
 {
     if (!$this->uid) {
         $this->redirect(array('site/login'));
     }
     if ($id) {
         $model = $this->loadModel($id);
     } else {
         $model = new SiteInfo();
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['SiteInfo'])) {
         $filter = Posts::handleContent($_POST['SiteInfo']['content']);
         $_POST['SiteInfo']['content'] = $filter['content'];
         if (!empty($filter['attachids'])) {
             $attkeys = array_filter(array_unique($filter['attachids']));
             if (!empty($attkeys)) {
                 $_POST['SiteInfo']['faceimg'] = $attkeys[0];
                 //默认将文章中的第一张图作为封面图
             }
         }
         $model->attributes = $_POST['SiteInfo'];
         if ($model->save()) {
             //将上传的图片置为通过
             Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'logid=:logid AND classify=:classify', array(':logid' => $model->id, ':classify' => 'siteinfo'));
             if (!empty($attkeys)) {
                 $attstr = join(',', $attkeys);
                 if ($attstr != '') {
                     Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED, 'logid' => $model->id), 'id IN(' . $attstr . ')');
                 }
             }
             $this->redirect(array('siteinfo/view', 'code' => $model->code));
         }
     }
     $this->render('/site/createSiteInfo', array('model' => $model));
 }
 /**
  * Clean up system by object ID-s
  * 
  * This function cleans up project objects recursively. It is also infinite 
  * loop safe because it will filter out ID-s that are already removed
  *
  * @param array $ids
  * @return null
  */
 function cleanUpByIds($ids)
 {
     static $cleaned_ids = array();
     // Remove objects that are already cleaned
     if (is_foreachable($ids)) {
         foreach ($ids as $k => $id) {
             if (isset($cleaned_ids[$id]) && $cleaned_ids[$id]) {
                 unset($ids[$k]);
             } else {
                 $cleaned_ids[$id] = false;
             }
             // if
         }
         // foreach
     }
     // if
     if (is_foreachable($ids)) {
         db_begin_work();
         Attachments::deleteByProjectObjectIds($ids);
         Subscriptions::deleteByObjectIds($ids);
         Assignments::deleteByObjectIds($ids);
         ActivityLogs::deleteByObjectIds($ids);
         StarredObjects::deleteByObjectIds($ids);
         Reminders::deleteByObjectIds($ids);
         search_index_remove($ids, 'ProjectObject');
         $rows = db_execute_all('SELECT DISTINCT id FROM ' . TABLE_PREFIX . 'project_objects WHERE parent_id IN (?)', $ids);
         if (is_foreachable($rows)) {
             $subobject_ids = array();
             foreach ($rows as $row) {
                 $subobject_ids[] = (int) $row['id'];
             }
             // foreach
             ProjectObjects::cleanUpByIds($subobject_ids);
         }
         // if
         ProjectObjects::delete(array('id IN (?)', $ids));
         foreach ($ids as $id) {
             $cleaned_ids[$id] = true;
         }
         // if
         db_commit();
     }
     // if
     return true;
 }
 * (or from the year in which this file was created to the year 2007) by
 * Cognizo Technologies, Inc. All Rights Reserved.
 *
 *
 * $Id: getAttachmentLocal.php 3078 2007-09-21 20:25:28Z will $
 */
$interface = new SecureAJAXInterface();
include_once './lib/CommonErrors.php';
include_once './lib/Attachments.php';
@ini_set('memory_limit', '256M');
if (!isset($_POST['id']) || !$interface->isRequiredIDValid('id')) {
    $interface->outputXMLErrorPage(-2, 'No attachment ID specified.');
    die;
}
$attachmentID = $_POST['id'];
$attachments = new Attachments(-1);
$rs = $attachments->get($attachmentID, false);
if (!isset($rs['directoryName']) || !isset($rs['storedFilename']) || md5($rs['directoryName']) != $_POST['directoryNameHash']) {
    $interface->outputXMLErrorPage(-2, 'Invalid directory name hash.');
    die;
}
$directoryName = $rs['directoryName'];
$fileName = $rs['storedFilename'];
/* Check for the existence of the backup.  If it is gone, send the user to a page informing them to press back and generate the backup again. */
if ($rs['contentType'] == 'catsbackup') {
    if (!file_exists('attachments/' . $directoryName . '/' . $fileName)) {
        $interface->outputXMLErrorPage(-2, 'The specified backup file no longer exists.  Please press back and regenerate the backup before downloading.  We are sorry for the inconvenience.');
        die;
    }
}
$url = 'attachments/' . $directoryName . '/' . $fileName;
Esempio n. 20
0
 public static function renderFormFieldByType($f, $values)
 {
     $value = isset($values[$f['id']]) ? $values[$f['id']] : '';
     $attributes = array();
     switch ($f['type']) {
         case 'file':
             $html = '';
             if ($value > 0) {
                 if ($a = Doctrine_Core::getTable('Attachments')->find($value)) {
                     $html = '<br>' . Attachments::getLink($a) . input_hidden_tag('extra_fields_files[' . $f['id'] . ']', $value) . '<br>' . input_checkbox_tag('extra_fields_files_delete[' . $f['id'] . ']', $value) . ' <label for="extra_fields_files_delete_' . $f['id'] . '">' . __('Delete') . '</label>';
                     $attributes['class'] = '';
                 }
             }
             return input_file_tag('extra_fields[' . $f['id'] . ']', '', $attributes) . $html;
             break;
         case 'number':
             return input_tag('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'text':
         case 'url':
             $attributes['size'] = '40';
             return input_tag('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'textarea':
             return textarea_tag('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'textarea_wysiwyg':
             if (isset($attributes['class'])) {
                 $attributes['class'] .= ' editor';
             } else {
                 $attributes['class'] = 'editor';
             }
             return textarea_tag('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'date':
             if (isset($attributes['class'])) {
                 $attributes['class'] .= ' datepicker';
             } else {
                 $attributes['class'] = 'datepicker';
             }
             $attributes['size'] = '11';
             return input_tag('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'date_range':
             if (isset($attributes['class'])) {
                 $attributes['class'] .= ' datepicker';
             } else {
                 $attributes['class'] = 'datepicker';
             }
             $attributes['size'] = '11';
             if (strlen($value) > 0) {
                 $value = explode('|', $value);
             } else {
                 $value = array('', '');
             }
             return __('From') . ': ' . input_tag('extra_fields[' . $f['id'] . '][from]', $value[0], $attributes) . ' ' . __('To') . ': ' . input_tag('extra_fields[' . $f['id'] . '][to]', $value[1], $attributes);
             break;
         case 'date_time':
             if (isset($attributes['class'])) {
                 $attributes['class'] .= ' datetimepicker';
             } else {
                 $attributes['class'] = 'datetimepicker';
             }
             $attributes['size'] = '17';
             return input_tag('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'date_dropdown':
             $years = range(date('Y') - 100, date('Y') + 20);
             $w = new sfWidgetFormDate(array('years' => array_combine($years, $years), 'format' => __('Year') . ':%year% ' . __('Month') . ':%month% ' . __('Day') . ':%day%'));
             return $w->render('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'pull_down':
             $choices = array();
             foreach (explode("\n", $f['default_values']) as $v) {
                 $choices[trim($v)] = trim($v);
             }
             return select_tag('extra_fields[' . $f['id'] . ']', $value, array('choices' => $choices), $attributes);
             break;
         case 'checkbox':
             $choices = array();
             foreach (explode("\n", $f['default_values']) as $v) {
                 $choices[trim($v)] = trim($v);
             }
             return '<div id="checkboxesList' . $f['id'] . '" class="checkboxesList">' . select_tag('extra_fields[' . $f['id'] . ']', explode("\n", $value), array('choices' => $choices, 'expanded' => true, 'multiple' => true), $attributes) . '</div>';
             break;
         case 'radiobox':
             $choices = array();
             foreach (explode("\n", $f['default_values']) as $v) {
                 $choices[trim($v)] = trim($v);
             }
             return select_tag('extra_fields[' . $f['id'] . ']', $value, array('choices' => $choices, 'expanded' => true), $attributes);
             break;
     }
 }
Esempio n. 21
0
/**
 *      [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2075 $
 */
define('CURSCRIPT', 'attachment');
require "libraries/common.inc.php";
require "share.inc.php";
if (isset($_GET['do'])) {
    $do = trim($_GET['do']);
    switch ($do) {
        case "download":
            uses("attachment");
            $attachment = new Attachments();
            if (empty($_GET['aid'])) {
                flash();
            }
            $attach_id = authcode(rawurldecode($_GET['aid']), "DECODE");
            if (empty($attach_id)) {
                flash();
            }
            require LIB_PATH . "func.download.php";
            require LIB_PATH . "js.class.php";
            $filename = rawurlencode($attachment->getAttachFileName($attach_id));
            $filename = $attachment->file_url;
            if (!sendFile($filename)) {
                exit('Error occured when get files.');
            } else {
                JS::Close();
Esempio n. 22
0
 private function onDeleteAttachment()
 {
     if ($this->_accessLevel < ACCESS_LEVEL_DELETE) {
         $this->listByView('Invalid user level for action.');
         return;
     }
     /* Bail out if we don't have a valid attachment ID. */
     if (!$this->isRequiredIDValid('attachmentID', $_GET)) {
         CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid attachment ID.');
     }
     /* Bail out if we don't have a valid joborder ID. */
     if (!$this->isRequiredIDValid('companyID', $_GET)) {
         CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid company ID.');
     }
     $companyID = $_GET['companyID'];
     $attachmentID = $_GET['attachmentID'];
     if (!eval(Hooks::get('CLIENTS_ON_DELETE_ATTACHMENT_PRE'))) {
         return;
     }
     $attachments = new Attachments($this->_siteID);
     $attachments->delete($attachmentID);
     if (!eval(Hooks::get('CLIENTS_ON_DELETE_ATTACHMENT_POST'))) {
         return;
     }
     CATSUtility::transferRelativeURI('m=companies&a=show&companyID=' . $companyID);
 }
Esempio n. 23
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         if ($form->getObject()->isNew()) {
             $project = Doctrine_Core::getTable('Projects')->find($request->getParameter('projects_id'));
             if ($request->getParameter('projects_types_id') > 0) {
                 $project->setProjectsTypesId($request->getParameter('projects_types_id'));
             }
             if ($request->getParameter('projects_status_id') > 0) {
                 $project->setProjectsStatusId($request->getParameter('projects_status_id'));
             }
             $project->save();
         }
         if ($form->getObject()->isNew()) {
             $form->setFieldValue('created_at', date('Y-m-d H:i:s'));
         }
         $projects_comments = $form->save();
         Attachments::insertAttachments($request->getFiles(), 'projectsComments', $projects_comments->getId(), $request->getParameter('attachments_info'), $this->getUser());
         ProjectsComments::sendNotification($this, $projects_comments, $this->getUser());
         $this->redirect('projectsComments/index?projects_id=' . $projects_comments->getProjectsId());
     }
 }
Esempio n. 24
0
 * PHPB2B :  Opensource B2B Script (http://www.phpb2b.com/)
 * Copyright (C) 2007-2010, Ualink. All Rights Reserved.
 * 
 * Licensed under The Languages Packages Licenses.
 * Support : phpb2b@hotmail.com
 * 
 * @version $Revision: 1393 $
 */
require "../libraries/common.inc.php";
require "room.share.php";
require LIB_PATH . 'page.class.php';
require CACHE_PATH . "cache_type.php";
uses("attachment", "album");
check_permission("album");
$attachment_controller = new Attachment('pic');
$attachment = new Attachments();
$album = new Albums();
$tpl_file = "album";
$page = new Pages();
if (empty($companyinfo)) {
    flash("pls_complete_company_info", "company.php", 0);
}
if (isset($_POST['do'])) {
    pb_submit_check('album');
    $vals = $_POST['album'];
    $vals['title'] = $title = trim($vals['title']);
    $vals['description'] = $description = trim($vals['description']);
    $now_album_amount = $attachment->findCount(null, "created>" . $today_start . " AND member_id=" . $_SESSION['MemberID']);
    if (!empty($_FILES['pic']['name'])) {
        $type_id = 1;
        $attach_id = empty($id) ? "album-" . $_SESSION['MemberID'] . "-" . ($album->getMaxId() + 1) : "album-" . $_SESSION['MemberID'] . "-" . $id;
Esempio n. 25
0
 /**
  * 验证用户具体发帖权限,并不影响其他权限
  * @param type $uid 验证的用户
  * @param type $type 验证的类型
  * @param type $field 是否检查总数
  * @return type
  */
 public static function check($type, $field = false, $uid = '')
 {
     if (!$uid) {
         $uid = Yii::app()->user->id;
     }
     if (!$uid) {
         if (zmf::config('officalUid')) {
             return array('status' => 1, 'msg' => '');
         }
         return array('status' => 0, 'msg' => '用户不存在');
     }
     $uinfo = Users::getUserInfo($uid);
     if (!$uinfo) {
         return array('status' => 0, 'msg' => '用户不存在');
     }
     if (!$uinfo['groupid']) {
         return array('status' => 0, 'msg' => '无组织用户');
     }
     $groupInfo = UserPower::model()->find('groupid=:gid', array(':gid' => $uinfo['groupid']));
     if (!$groupInfo) {
         return array('status' => 0, 'msg' => '无组织用户');
     }
     $num = $groupInfo->getAttribute($type);
     if ($num === null) {
         return array('status' => 0, 'msg' => '无法完成验证的type:' . $type);
     } elseif ($num === 0) {
         return array('status' => 0, 'msg' => '不允许');
     } elseif ($field) {
         switch ($field) {
             case 'addPost':
                 $totalNum = $groupInfo['postNum'];
                 $hasNum = Posts::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addQuestion':
                 $totalNum = $groupInfo['questionNum'];
                 $hasNum = Question::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addAnswer':
                 $totalNum = $groupInfo['answerNum'];
                 $hasNum = Answer::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addPoiPost':
                 $totalNum = $groupInfo['poiPostNum'];
                 $hasNum = PoiPost::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addPoiTips':
                 $totalNum = $groupInfo['poiTipsNum'];
                 $hasNum = PoiTips::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addImage':
                 $totalNum = $groupInfo['imageNum'];
                 $hasNum = Attachments::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addComment':
                 $totalNum = $groupInfo['commentNum'];
                 $hasNum = Comments::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addPlan':
                 $totalNum = $groupInfo['planNum'];
                 $hasNum = Plans::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'yueban':
                 $totalNum = $groupInfo['yuebanNum'];
                 $hasNum = Posts::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
         }
         if (!$totalNum) {
             return array('status' => 1, 'msg' => '无限制');
         } else {
             if ($hasNum >= $totalNum) {
                 return array('status' => 0, 'msg' => '已超出限制:' . $totalNum);
             } else {
                 return array('status' => 1, 'msg' => '');
             }
         }
     } else {
         return array('status' => 1, 'msg' => '');
     }
 }
Esempio n. 26
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         if ($form->getObject()->isNew()) {
             $tasks = Doctrine_Core::getTable('Tasks')->find($request->getParameter('tasks_id'));
             if ($form->getValue('tasks_priority_id') > 0) {
                 $tasks->setTasksPriorityId($form->getValue('tasks_priority_id'));
             } else {
                 unset($form['tasks_priority_id']);
             }
             if ($request->getParameter('tasks_labels_id') > 0) {
                 $tasks->setTasksLabelId($request->getParameter('tasks_labels_id'));
             }
             if ($request->getParameter('tasks_types_id') > 0) {
                 $tasks->setTasksTypeId($request->getParameter('tasks_types_id'));
             }
             if (strlen($form->getValue('due_date')) > 0) {
                 $tasks->setDueDate($form->getValue('due_date'));
             } else {
                 unset($form['due_date']);
             }
             if ($request->getParameter('progress') > 0) {
                 $tasks->setProgress($request->getParameter('progress'));
             }
             if ($form->getValue('tasks_status_id') > 0) {
                 $tasks->setTasksStatusId($form->getValue('tasks_status_id'));
                 if (in_array($form->getValue('tasks_status_id'), app::getStatusByGroup('closed', 'TasksStatus'))) {
                     $tasks->setClosedDate(date('Y-m-d H:i:s'));
                     $tasks->save();
                 }
                 if (!in_array($form->getValue('tasks_status_id'), app::getStatusByGroup('closed', 'TasksStatus'))) {
                     $tasks->setClosedDate(null);
                     $tasks->save();
                 }
             } else {
                 unset($form['tasks_status_id']);
             }
             $tasks->save();
         }
         if ($form->getObject()->isNew() and sfConfig::get('app_allow_adit_tasks_comments_date') != 'on') {
             $form->setFieldValue('created_at', date('Y-m-d H:i:s'));
         }
         $tasks_comments = $form->save();
         Attachments::insertAttachments($request->getFiles(), 'comments', $tasks_comments->getId(), $request->getParameter('attachments_info'), $this->getUser());
         TasksComments::sendNotification($this, $tasks_comments, $this->getUser());
         $this->redirect('tasksComments/index?projects_id=' . $request->getParameter('projects_id') . '&tasks_id=' . $request->getParameter('tasks_id'));
     }
 }
 public function taskimage()
 {
     $doc_id = Input::get('doc_id');
     $custom1 = Input::get('custom1');
     $custom2 = Input::get('custom2');
     $custom3 = Input::get('custom3');
     Session::put('custom1', $custom1);
     Session::put('custom2', $custom2);
     Session::put('custom3', $custom3);
     //Image Upload
     foreach (Input::file('file') as $file) {
         $rules = array('file' => 'required|mimes:png,gif,jpeg,jpg|max:900000000000000000000');
         $validator = \Validator::make(array('file' => $file), $rules);
         $destine = public_path() . "/uploads";
         if ($validator->passes()) {
             $ext = $file->guessClientExtension();
             // (Based on mime type)
             $ext = $file->getClientOriginalExtension();
             // (Based on filename)
             $filename = $file->getClientOriginalName();
             $archivo = value(function () use($file) {
                 $filename = str_random(10) . '.' . $file->getClientOriginalExtension();
                 return strtolower($filename);
             });
             $archivo = value(function () use($file) {
                 $date = date('m-d-Y-h-i-s', time());
                 $filename = $date . "-" . $file->getClientOriginalName();
                 return strtolower($filename);
             });
             $attach = new Attachments();
             $attach->doc_id = $doc_id;
             $attach->data = $archivo;
             $attach->saved = 1;
             $attach->save();
             $filename = $doc_id . "_" . $attach->id;
             $file->move($destine, $archivo);
             $target_folder = $destine;
             $upload_image = $target_folder . "/" . $archivo;
             $thumbnail = $target_folder . "/resize" . $archivo;
             $actual = $target_folder . "/" . $archivo;
             // THUMBNAIL SIZE
             list($width, $height) = getimagesize($upload_image);
             $newwidth = $width;
             $newheight = $height;
             while ($newheight > 525) {
                 $newheight = $newheight * 0.8;
                 $newwidth = $newwidth * 0.8;
             }
             $source = $upload_image;
             $ext = strtolower($ext);
             $thumb = imagecreatetruecolor($newwidth, $newheight);
             if ($ext == "jpg" || $ext == "jpeg") {
                 $source = imagecreatefromjpeg($upload_image);
             } elseif ($ext == "png") {
                 $source = imagecreatefrompng($upload_image);
             } elseif ($ext == "gif") {
                 $source = imagecreatefromgif($upload_image);
             } else {
                 continue;
             }
             // RESIZE
             imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
             // MAKE NEW FILES
             if ($ext == "jpg" || $ext == "jpeg") {
                 imagejpeg($thumb, $thumbnail, 100);
             } elseif ($ext == "png") {
                 imagepng($thumb, $thumbnail, 9);
             } elseif ($ext == "gif") {
                 imagegif($thumb, $thumbnail, 100);
             } else {
                 echo "An invalid image";
             }
             unlink($actual);
             // FILE RENAMES
             rename($thumbnail, $actual);
         } else {
             $errors = $validator->errors();
             Session::put('imgerror', 'Invalid file.');
         }
     }
     Session::put('imgsuccess', 'Files uploaded.');
     if (Session::get('imgerror')) {
         Session::forget('imgsuccess');
     }
     return Redirect::back()->withInput();
     //End Image Upload
 }
Esempio n. 28
0
if (count($fields) > 1) {
    ?>
                <div class="swiper-button-prev"></div>
                <div class="swiper-button-next"></div>
            <?php 
}
?>
               
            </div>         
        <a href="#project-inside" class="discover-more">Discover</a>



 <?php 
$gallery = array();
$attachments = new Attachments('attachments', get_the_ID());
if ($attachments->exist()) {
    while ($attachments->get()) {
        array_push($gallery, $attachments->src('full'));
    }
}
//ottengo il contenuto
$content = "";
if (have_posts()) {
    // Start the loop.
    while (have_posts()) {
        the_post();
        $content = get_the_content();
        // End the loop.
    }
}
Esempio n. 29
0
 /**
  * Removes a candidate and all associated records from the system.
  *
  * @param integer Candidate ID to delete.
  * @return void
  */
 public function delete($candidateID)
 {
     /* Delete the candidate from candidate. */
     $sql = sprintf("DELETE FROM\n                candidate\n            WHERE\n                candidate_id = %s\n            AND\n                site_id = %s", $this->_db->makeQueryInteger($candidateID), $this->_siteID);
     $this->_db->query($sql);
     $history = new History($this->_siteID);
     $history->storeHistoryDeleted(DATA_ITEM_CANDIDATE, $candidateID);
     /* Delete pipeline entries from candidate_joborder. */
     $sql = sprintf("DELETE FROM\n                candidate_joborder\n            WHERE\n                candidate_id = %s\n            AND\n                site_id = %s", $this->_db->makeQueryInteger($candidateID), $this->_siteID);
     $this->_db->query($sql);
     /* Delete pipeline history from candidate_joborder_status_history. */
     $sql = sprintf("DELETE FROM\n                candidate_joborder_status_history\n            WHERE\n                candidate_id = %s\n            AND\n                site_id = %s", $this->_db->makeQueryInteger($candidateID), $this->_siteID);
     $this->_db->query($sql);
     /* Delete from saved lists. */
     $sql = sprintf("DELETE FROM\n                saved_list_entry\n            WHERE\n                data_item_id = %s\n            AND\n                site_id = %s\n            AND\n                data_item_type = %s", $this->_db->makeQueryInteger($candidateID), $this->_siteID, DATA_ITEM_CANDIDATE);
     $this->_db->query($sql);
     /* Delete attachments. */
     $attachments = new Attachments($this->_siteID);
     $attachmentsRS = $attachments->getAll(DATA_ITEM_CANDIDATE, $candidateID);
     foreach ($attachmentsRS as $rowNumber => $row) {
         $attachments->delete($row['attachmentID']);
     }
     /* Delete extra fields. */
     $this->extraFields->deleteValueByDataItemID($candidateID);
 }
Esempio n. 30
0
function get_banner($banner_slug, $echo = true, $url_and_link = false)
{
    $banner_id = get_post_id_by_slug($banner_slug, 'banners');
    $banners = new Attachments('banner_attachments', $banner_id);
    $output = "";
    if ($banners->exist()) {
        $i = 0;
        //пишем всю эту муть.. там в Attachments::()->OneSort();
        $o = $banners->OneSort();
        if (empty($o)) {
            $o = 0;
        }
        //ты втираешь мне какуюто Дичь!?
        if ($banners->total() > 1) {
            if (!session_id()) {
                session_start();
            }
            if (!isset($_SESSION[$banner_slug])) {
                $_SESSION[$banner_slug] = $o;
                $_SESSION[start] = true;
            } else {
                $_SESSION[start] = false;
            }
            $i = intval($_SESSION[$banner_slug]);
            //извольте?!?
            if ($_SESSION[start]) {
                $i = $i;
            } else {
                if ($i < $banners->total() - 1) {
                    $_SESSION[$banner_slug] = ++$i;
                } else {
                    $_SESSION[$banner_slug] = $i = 0;
                }
            }
        }
        if ($banners->get_single($i)) {
            if ($url_and_link) {
                return array('url' => $banners->url($i), 'link' => $banners->field('link_url', $i));
            }
            if ($banners->type($i) == 'image') {
                $b_url = $banners->field('link_url', $i);
                if (!empty($b_url)) {
                    $output .= '<noindex><a rel="nofollow" href="' . $b_url . '" target="_blank">';
                }
                $output .= '<img src="' . $banners->url($i) . '" width="100%" />';
                if (!empty($b_url)) {
                    $output .= '</a></noindex>';
                }
            }
            if ($banners->type($i) == 'application') {
                $hb = explode("x", $banner_slug);
                $parent_id = $banner_slug . '_' . $banners->id($i);
                $output .= '<div id="' . $parent_id . '"><script type="text/javascript">';
                $output .= 'swfobject.embedSWF("' . $banners->url($i) . '", "' . $parent_id . '", "100%", "' . $hb[1] . '", "10.0.0", "install flash player", null, {menu: "false", wmode: "transparent", scale:"default"}, null);';
                $output .= '</script></div>';
            }
        }
    } else {
        if ($echo) {
            echo $output;
        } else {
            return false;
        }
    }
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}