当前位置: 首页>>代码示例>>PHP>>正文


PHP can_add函数代码示例

本文整理汇总了PHP中can_add函数的典型用法代码示例。如果您正苦于以下问题:PHP can_add函数的具体用法?PHP can_add怎么用?PHP can_add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了can_add函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit_timeslot

 function edit_timeslot()
 {
     if (!can_add(logged_user(), active_context(), Timeslots::instance()->getObjectTypeId())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     ajx_current("empty");
     $timeslot_data = array_var($_POST, 'timeslot');
     $timeslot = Timeslots::findById(array_var($timeslot_data, 'id', 0));
     if (!$timeslot instanceof Timeslot) {
         flash_error(lang('timeslot dnx'));
         return;
     }
     try {
         $hoursToAdd = array_var($timeslot_data, 'hours', 0);
         $minutes = array_var($timeslot_data, 'minutes', 0);
         if (strpos($hoursToAdd, ',') && !strpos($hoursToAdd, '.')) {
             $hoursToAdd = str_replace(',', '.', $hoursToAdd);
         }
         if (strpos($hoursToAdd, ':') && !strpos($hoursToAdd, '.')) {
             $pos = strpos($hoursToAdd, ':') + 1;
             $len = strlen($hoursToAdd) - $pos;
             $minutesToAdd = substr($hoursToAdd, $pos, $len);
             if (!strlen($minutesToAdd) <= 2 || !strlen($minutesToAdd) > 0) {
                 $minutesToAdd = substr($minutesToAdd, 0, 2);
             }
             $mins = $minutesToAdd / 60;
             $hours = substr($hoursToAdd, 0, $pos - 1);
             $hoursToAdd = $hours + $mins;
         }
         if ($minutes) {
             $min = str_replace('.', '', $minutes / 6);
             $hoursToAdd = $hoursToAdd + ("0." . $min);
         }
         if ($hoursToAdd <= 0) {
             flash_error(lang('time has to be greater than 0'));
             return;
         }
         $startTime = getDateValue(array_var($timeslot_data, 'date'));
         $startTime = $startTime->add('h', 8 - logged_user()->getTimezone());
         $endTime = getDateValue(array_var($timeslot_data, 'date'));
         $endTime = $endTime->add('h', 8 - logged_user()->getTimezone() + $hoursToAdd);
         $timeslot_data['start_time'] = $startTime;
         $timeslot_data['end_time'] = $endTime;
         $timeslot_data['name'] = $timeslot_data['description'];
         //Only admins can change timeslot user
         if (array_var($timeslot_data, 'contact_id', false) && !logged_user()->isAdministrator()) {
             $timeslot_data['contact_id'] = $timeslot->getContactId();
         }
         $timeslot->setFromAttributes($timeslot_data);
         $user = Contacts::findById($timeslot_data['contact_id']);
         $billing_category_id = $user->getDefaultBillingId();
         $bc = BillingCategories::findById($billing_category_id);
         if ($bc instanceof BillingCategory) {
             $timeslot->setBillingId($billing_category_id);
             $hourly_billing = $bc->getDefaultValue();
             $timeslot->setHourlyBilling($hourly_billing);
             $timeslot->setFixedBilling($hourly_billing * $hoursToAdd);
             $timeslot->setIsFixedBilling(false);
         }
         DB::beginWork();
         $timeslot->save();
         $member_ids = json_decode(array_var($_POST, 'members', ''));
         if ($member_ids && count($member_ids)) {
             ajx_add("time-panel", "reload");
         } else {
             foreach (active_context() as $dimension) {
                 $names[] = $dimension->getName();
             }
             flash_error(lang('select member to add timeslots', implode(", ", $names)));
             //flash_error(lang('must choose at least one member'));
             DB::rollback();
             return;
         }
         $object_controller = new ObjectController();
         $object_controller->add_to_members($timeslot, $member_ids);
         DB::commit();
         ajx_extra_data(array("timeslot" => $timeslot->getArrayInfo()));
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
     // try
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:85,代码来源:TimeController.class.php

示例2: canAdd

 function canAdd(Contact $user, $context, &$notAllowedMember = '')
 {
     $object = $this->getRelObject();
     return can_add($user, $context, $object->getObjectTypeId(), $notAllowedMember);
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:5,代码来源:Comment.class.php

示例3: canAdd

	/**
	 * Check if specific user can add contacts to specific project
	 *
	 * @access public
	 * @param Contact $user
	 * @param Project $project
	 * @return booelean
	 */
	function canAdd(Contact $user, $context, &$notAllowedMember = '') {
		return can_add($user, $context, $this->getObjectTypeId(), $notAllowedMember);
	} // canAdd
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:11,代码来源:MailContent.class.php

示例4: quick_add

 function quick_add($table_name, $ajax = FALSE)
 {
     checklogin();
     if (!can_add($table_name)) {
         exit('Sorry. You do not have the permission to add items to ' . humanizer($table_name));
     }
     if (stripos(uri_string(), ':')) {
         $mess = explode(':', uri_string());
         if (count($mess) > 2) {
             $data['s_message'] = $mess[2];
             $data['s_status'] = $mess[1];
         }
     }
     $table_name = mysql_real_escape_string($table_name);
     $sql = "SELECT column_name, is_nullable, data_type, character_maximum_length, column_key, column_comment, column_type, column_default  FROM information_schema.COLUMNS WHERE TABLE_NAME='{$table_name}' AND TABLE_SCHEMA='" . DATABASE . "'";
     $data['fields'] = $this->db->query($sql)->result();
     $data['table_name'] = $table_name;
     /*** SET VALIDATION RULES ***/
     $data_types_xss = array('text', 'longtext', 'enum', 'datetime', 'tinyint');
     foreach ($data['fields'] as $field) {
         $rules = '';
         if ($field->column_name != 'id' && ($field->is_nullable == 'NO' || ($field->column_name == 'title' || $field->column_name == 'name'))) {
             $rules = 'required|';
         }
         if ($field->character_maximum_length && $field->column_name != 'id') {
             $rules .= 'max_length[' . $field->character_maximum_length . ']';
         }
         if (!in_array($field->data_type, $data_types_xss)) {
             $rules .= 'xss_clean|';
         }
         if ($field->data_type == 'int') {
             $rules .= 'numeric|';
         }
         if ($field->column_name != "merchant_sub_category") {
             $this->form_validation->set_message('numeric', '%s is required.');
             $this->form_validation->set_rules($field->column_name, humanize(rtrim($field->column_name, '_id')), rtrim($rules, '|'));
         }
     }
     /*** END VALIDATION RULES ***/
     /*** WHEN POSTING OCCURS ***/
     if ($_POST) {
         if ($this->form_validation->run() == TRUE) {
             //it passed. insert into table
             if (key_exists('_continue', $_POST)) {
                 $_continue = $_POST['_continue'];
                 unset($_POST['_continue']);
             }
             if (key_exists('_unlink', $_POST)) {
                 $_unlink = $_POST['_unlink'];
                 unset($_POST['_unlink']);
                 foreach ($_unlink as $roguefiles) {
                     if (strlen($roguefiles) > 0) {
                         if (file_exists($_SERVER['DOCUMENT_ROOT'] . $roguefiles)) {
                             unlink($_SERVER['DOCUMENT_ROOT'] . $roguefiles);
                         }
                     }
                 }
             }
             foreach ($_POST as $key => $val) {
                 if ($val == 'NULL') {
                     unset($_POST[$key]);
                 }
                 if ($key == 'password') {
                     $_POST[$key] = md5($val);
                 }
             }
             $this->db->insert($table_name, $_POST);
             //$this->memcached_library->flush();
             $dataid = mysql_insert_id();
             if (isset($_continue) && $_continue) {
                 $_continue = trim(strtolower($_continue));
             } else {
                 $_continue = '';
             }
             //depending on where they want to go afterwards, redir as follows
             if ($_continue == 'add and return to list') {
                 redirect('content/' . $table_name . '/:success:Item Added Successfully');
             } elseif ($_continue == 'add and add another') {
                 redirect('content/' . $table_name . '/add/:success:Item Added Successfully');
             } else {
                 redirect('content/edit/' . $table_name . '/' . $dataid . '/:success:Item Added Successfully');
             }
         }
     }
     /*** END POST ***/
     $this->load->view('includes/light_header');
     $this->load->view('includes/quickadd', $data);
 }
开发者ID:reesretuta,项目名称:beauty-mx,代码行数:88,代码来源:content.php

示例5: addEmailToWorkspace

 function addEmailToWorkspace($id, $destination, $mantainWs = true)
 {
     $email = MailContents::findById($id);
     if ($email instanceof MailContent && $email->canEdit(logged_user())) {
         if (!$mantainWs) {
             $removed = "";
             $ws = $email->getWorkspaces();
             foreach ($ws as $w) {
                 if (can_add(logged_user(), $w, 'MailContents')) {
                     $email->removeFromWorkspace($w);
                     $removed .= $w->getId() . ",";
                 }
             }
             $removed = substr($removed, 0, -1);
             $log_action = ApplicationLogs::ACTION_MOVE;
             $log_data = ($removed == "" ? "" : "from:{$removed};") . "to:" . $destination->getId();
         } else {
             $log_action = ApplicationLogs::ACTION_COPY;
             $log_data = "to:" . $destination->getId();
         }
         $email->addToWorkspace($destination);
         ApplicationLogs::createLog($email, $email->getWorkspaces(), $log_action, false, null, true, $log_data);
         return 1;
     } else {
         return 0;
     }
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:27,代码来源:MailController.class.php

示例6: canAdd

 function canAdd(Contact $user, $context, &$notAllowedMember = '')
 {
     return can_manage_contacts($user) || can_add($user, $context, Contacts::instance()->getObjectTypeId(), $notAllowedMember);
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:4,代码来源:Contact.class.php

示例7: lang

  </div>

	<table style="margin-top:10px;">
<?php 
if (can_manage_time(logged_user())) {
    echo '<tr><td style="vertical-align:middle;"><span class="bold">' . lang("person") . ':&nbsp;</span></td>';
    if (logged_user()->isMemberOfOwnerCompany()) {
        $users = Contacts::getAllUsers();
    } else {
        $users = logged_user()->getCompanyId() > 0 ? Contacts::getAllUsers(" AND `company_id` = " . logged_user()->getCompanyId()) : array(logged_user());
    }
    $tmp_users = array();
    foreach ($users as $user) {
        $rel_object = $timeslot->getRelObject();
        $is_assigned = $rel_object instanceof ProjectTask && $rel_object->getAssignedToContactId() == $user->getId();
        if ($is_assigned || can_add($user, $rel_object->getMembers(), Timeslots::instance()->getObjectTypeId())) {
            $tmp_users[] = $user;
        }
    }
    $users = $tmp_users;
    $user_options = array();
    foreach ($users as $user) {
        $user_options[] = option_tag($user->getObjectName(), $user->getId(), array_var($timeslot_data, 'contact_id') == $user->getId() ? array("selected" => "selected") : null);
    }
    echo '<td>' . select_box("timeslot[contact_id]", $user_options, array('id' => $genid . 'tsUser', 'tabindex' => '15')) . '</td></tr>';
    echo '<tr><td>&nbsp;</td></tr>';
}
?>
		<tr>
			<td style="vertical-align:middle;"><span class="bold"><?php 
echo lang("start date");
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:31,代码来源:add_timeslot.php

示例8: canAdd

 static function canAdd()
 {
     self::includeBasic();
     $workspace_id = self::ogWorkspaceId();
     if ($workspace_id == null) {
         return false;
     }
     $workspace = Projects::findById($workspace_id);
     if (!$workspace instanceof Project) {
         return false;
     }
     return can_add(self::getCompanyWebsite()->getLoggedUser(), $workspace, 'ProjectFiles');
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:13,代码来源:OgHelper.class.php

示例9: add_page_action

        if ($file->canEdit(logged_user())) {
            if ($file->isModifiable() && $file->getType() != ProjectFiles::TYPE_WEBLINK) {
                add_page_action(lang('edit this file'), $file->getModifyUrl(), 'ico-edit', null, null, true);
            }
            add_page_action(lang('update file'), $file->getEditUrl(), 'ico-properties', null, null, true);
        }
    }
    if ($file->canDelete(logged_user())) {
        if ($file->isTrashed()) {
            add_page_action(lang('restore from trash'), "javascript:if(confirm(lang('confirm restore objects'))) og.openLink('" . $file->getUntrashUrl() . "');", 'ico-restore', null, null, true);
            add_page_action(lang('delete permanently'), "javascript:if(confirm(lang('confirm delete permanently'))) og.openLink('" . $file->getDeletePermanentlyUrl() . "');", 'ico-delete', null, null, true);
        } else {
            add_page_action(lang('move to trash'), "javascript:if(confirm(lang('confirm move to trash'))) og.openLink('" . $file->getTrashUrl() . "');", 'ico-trash', null, null, true);
        }
    }
    if (can_add(logged_user(), active_or_personal_project(), 'ProjectFiles') && $file->getType() != ProjectFiles::TYPE_WEBLINK) {
        add_page_action(lang('copy file'), $file->getCopyUrl(), 'ico-copy');
    }
    ?>


<div style="padding:7px">
<div class="files">

<?php 
    $description = '';
    if ($last_revision instanceof ProjectFileRevision) {
        $description .= '<div id="fileLastRevision"><span class="propertyName">' . lang('last revision') . ':</span>';
        if ($last_revision->getCreatedBy() instanceof User) {
            $description .= lang('file revision info long', $last_revision->getRevisionNumber(), $last_revision->getCreatedBy()->getCardUrl(), clean($last_revision->getCreatedBy()->getDisplayName()), format_descriptive_date($last_revision->getCreatedOn()));
        } else {
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:31,代码来源:file_details.php

示例10: canAdd

	/**
	 * Empty implementation of static method.
	 *
	 * Add tag permissions are done through ProjectDataObject::canBillingCategory() method. This
	 * will return BillingCategory permissions for specified object
	 *
	 * @param User $user
	 * @param Project $project
	 * @return boolean
	 */
	function canAdd(Contact $user, Project $project) {		
		return can_add($user,$project,get_class(BillingCategories::instance()));
	} // canAdd
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:13,代码来源:BillingCategory.class.php

示例11: add_to_members

 function add_to_members($object, $member_ids, $user = null, $check_allowed_members = true)
 {
     if (!$user instanceof Contact) {
         $user = logged_user();
     }
     // clean member_ids
     $tmp_mids = array();
     foreach ($member_ids as $mid) {
         if (!is_null($mid) && trim($mid) != "") {
             $tmp_mids[] = $mid;
         }
     }
     $member_ids = $tmp_mids;
     if ($user->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     if (isset($_POST['trees_not_loaded']) && $_POST['trees_not_loaded'] > 0) {
         return;
     }
     $required_dimension_ids = array();
     $dimension_object_types = $object->getDimensionObjectTypes();
     foreach ($dimension_object_types as $dot) {
         if ($dot->getIsRequired()) {
             $required_dimension_ids[] = $dot->getDimensionId();
         }
     }
     $required_dimensions = Dimensions::findAll(array("conditions" => "id IN (" . implode(",", $required_dimension_ids) . ") OR is_required=1"));
     // If not entered members
     /*if (count($member_ids) <= 0){
     			$throw_error = true;
     			if (Plugins::instance()->isActivePlugin('core_dimensions')) {
     				$personal_member = Members::findById($user->getPersonalMemberId());
     				if ($personal_member instanceof Member) {
     					$member_ids[] = $user->getPersonalMemberId();
     				}
     			}
     		}*/
     if (count($member_ids) > 0) {
         $enteredMembers = Members::findAll(array('conditions' => 'id IN (' . implode(",", $member_ids) . ')'));
     } else {
         $enteredMembers = array();
     }
     $manageable_members = array();
     foreach ($enteredMembers as $ent_mem) {
         if ($ent_mem->getDimension()->getIsManageable() && $ent_mem->getDimension()->getDefinesPermissions()) {
             $manageable_members[] = $ent_mem;
         }
     }
     if (!can_add($user, $check_allowed_members ? $object->getAllowedMembersToAdd($user, $manageable_members) : $manageable_members, $object->getObjectTypeId()) && !($object instanceof TemplateTask || $object instanceof TemplateMilestone || $object instanceof Contact && $object->isUser())) {
         $dinfos = DB::executeAll("SELECT name, code, options FROM " . TABLE_PREFIX . "dimensions WHERE is_manageable = 1");
         $dimension_names = array();
         foreach ($dinfos as $dinfo) {
             $dimension_names[] = json_decode($dinfo['options'])->useLangs ? lang($dinfo['code']) : $dinfo['name'];
         }
         throw new Exception(lang('must choose at least one member of', implode(', ', $dimension_names)));
         ajx_current("empty");
         return;
     }
     $removedMemebersIds = $object->removeFromMembers($user, $enteredMembers);
     /* @var $object ContentDataObject */
     $validMembers = $check_allowed_members ? $object->getAllowedMembersToAdd($user, $enteredMembers) : $enteredMembers;
     foreach ($required_dimensions as $rdim) {
         $exists = false;
         foreach ($validMembers as $m) {
             if ($m->getDimensionId() == $rdim->getId()) {
                 $exists = true;
                 break;
             }
         }
         if (!$exists) {
             throw new Exception(lang('must choose at least one member of', $rdim->getName()));
         }
     }
     $object->addToMembers($validMembers, true);
     Hook::fire('after_add_to_members', $object, $validMembers);
     Hook::fire('after_remove_members_from_object', $object, $removedMemebersIds);
     $object->addToSharingTable();
     //add to the object instance the members only if members value of the object is not null
     //because in that case when we ask for the members of the object we load them from db
     if (!is_null($object->members)) {
         $object->members = $validMembers;
     }
     return $validMembers;
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:86,代码来源:ObjectController.class.php

示例12: lang

	<table style="margin-top:10px;">
<?php
	if (can_manage_time(logged_user())) {
		echo '<tr><td style="vertical-align:middle;"><span class="bold">' . lang("person") . ':&nbsp;</span></td>';
		
		if (logged_user()->isMemberOfOwnerCompany()) {
			$users = Contacts::getAllUsers();
		} else {
			$users = logged_user()->getCompanyId() > 0 ? Contacts::getAllUsers(" AND `company_id` = ". logged_user()->getCompanyId()) : array(logged_user());
		}
		$tmp_users = array();
		foreach ($users as $user) {
			$rel_object = $timeslot->getRelObject();
			$is_assigned = ($rel_object instanceof ProjectTask && $rel_object->getAssignedToContactId() == $user->getId());
			if ($is_assigned || can_add($user, active_context(), Timeslots::instance()->getObjectTypeId())) {
				$tmp_users[] = $user;
			}
		}
		$users = $tmp_users;
		
		$user_options = array();
		foreach ($users as $user) {
			$user_options[] = option_tag($user->getObjectName(), $user->getId(), array_var($timeslot_data, 'contact_id') == $user->getId() ? array("selected" => "selected") : null);
		}
		echo '<td>' . select_box("timeslot[contact_id]", $user_options, array('id' => $genid . 'tsUser', 'tabindex' => '15')) . '</td></tr>';
		echo '<tr><td>&nbsp;</td></tr>';
	}
?>
		<tr>
			<td style="vertical-align:middle;"><span class="bold"><?php echo lang("start date") ?>:&nbsp;</span></td>
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:30,代码来源:add_timeslot.php

示例13: list_all


//.........这里部分代码省略.........
                         // try
                     }
                     //for
                     if ($succ <= 0) {
                         flash_error(lang("error markasread files", $err));
                     }
                 } else {
                     if (array_var($_GET, 'action') == 'markasunread') {
                         $ids = explode(',', array_var($_GET, 'ids'));
                         $succ = 0;
                         $err = 0;
                         foreach ($ids as $id) {
                             $webpage = ProjectWebpages::findById($id);
                             try {
                                 $webpage->setIsRead(logged_user()->getId(), false);
                                 $succ++;
                             } catch (Exception $e) {
                                 $err++;
                             }
                             // try
                         }
                         //for
                         if ($succ <= 0) {
                             flash_error(lang("error markasunread files", $err));
                         }
                     } else {
                         if (array_var($_GET, 'action') == 'move') {
                             $wsid = array_var($_GET, "moveTo");
                             $destination = Projects::findById($wsid);
                             if (!$destination instanceof Project) {
                                 $resultMessage = lang('project dnx');
                                 $resultCode = 1;
                             } else {
                                 if (!can_add(logged_user(), $destination, 'ProjectWebpages')) {
                                     $resultMessage = lang('no access permissions');
                                     $resultCode = 1;
                                 } else {
                                     $count = 0;
                                     $ids = explode(',', array_var($_GET, 'ids', ''));
                                     for ($i = 0; $i < count($ids); $i++) {
                                         $id = $ids[$i];
                                         $webpage = ProjectWebpages::findById($id);
                                         if ($webpage instanceof ProjectWebpage && $webpage->canEdit(logged_user())) {
                                             if (!array_var($_GET, "mantainWs")) {
                                                 $removed = "";
                                                 $ws = $webpage->getWorkspaces();
                                                 foreach ($ws as $w) {
                                                     if (can_add(logged_user(), $w, 'ProjectWebpages')) {
                                                         $webpage->removeFromWorkspace($w);
                                                         $removed .= $w->getId() . ",";
                                                     }
                                                 }
                                                 $removed = substr($removed, 0, -1);
                                                 $log_action = ApplicationLogs::ACTION_MOVE;
                                                 $log_data = ($removed == "" ? "" : "from:{$removed};") . "to:{$wsid}";
                                             } else {
                                                 $log_action = ApplicationLogs::ACTION_COPY;
                                                 $log_data = "to:{$wsid}";
                                             }
                                             $webpage->addToWorkspace($destination);
                                             ApplicationLogs::createLog($webpage, $webpage->getWorkspaces(), $log_action, false, null, true, $log_data);
                                             $count++;
                                         }
                                     }
                                     // for
                                     $resultMessage = lang("success move objects", $count);
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:67,代码来源:WebpageController.class.php

示例14: canAdd

	function canAdd(Contact $user, $context, &$notAllowedMember = ''){
		$object = $this->getRelObject();
		if (!$object instanceof ContentDataObject) {
			return false;
		}
		return can_add($user, $context, $object->getObjectTypeId(), $notAllowedMember );
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:7,代码来源:Comment.class.php

示例15: move

 function move()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     ajx_current("empty");
     $ids = array_var($_GET, 'ids');
     if (!$ids) {
         return;
     }
     $wsid = array_var($_GET, 'ws');
     $keep = array_var($_GET, 'keep', 1) == 1;
     $atts = array_var($_GET, 'atts', 0) == 1;
     $workspace = Projects::findById($wsid);
     if (!$workspace instanceof Project) {
         flash_error(lang('project dnx'));
         return;
     }
     $id_list = explode(",", $ids);
     $err = 0;
     $succ = 0;
     foreach ($id_list as $cid) {
         list($manager, $id) = explode(":", $cid);
         if (isset($maganer) && $maganer == 'Projects') {
             continue;
         }
         try {
             $obj = get_object_by_manager_and_id($id, $manager);
             if ($obj instanceof ProjectDataObject && $obj->canEdit(logged_user())) {
                 if ($obj instanceof MailContent) {
                     $conversation = MailContents::getMailsFromConversation($obj);
                     $count = 0;
                     foreach ($conversation as $conv_email) {
                         $count += MailController::addEmailToWorkspace($conv_email->getId(), $workspace, $keep);
                         if (array_var($_GET, 'atts') && $conv_email->getHasAttachments()) {
                             MailUtilities::parseMail($conv_email->getContent(), $decoded, $parsedEmail, $warnings);
                             $classification_data = array();
                             for ($j = 0; $j < count(array_var($parsedEmail, "Attachments", array())); $j++) {
                                 $classification_data["att_" . $j] = true;
                             }
                             $tags = implode(",", $conv_email->getTagNames());
                             MailController::classifyFile($classification_data, $conv_email, $parsedEmail, array($workspace), $keep, $tags);
                         }
                     }
                     $succ++;
                 } else {
                     $remain = 0;
                     if (!$keep || $obj instanceof ProjectTask || $obj instanceof ProjectMilestone) {
                         // Tasks and Milestones can have only 1 workspace
                         $removed = "";
                         $ws = $obj->getWorkspaces();
                         foreach ($ws as $w) {
                             if (can_add(logged_user(), $w, get_class($obj->manager()))) {
                                 $obj->removeFromWorkspace($w);
                                 $removed .= $w->getId() . ",";
                             } else {
                                 $remain++;
                             }
                         }
                         $removed = substr($removed, 0, -1);
                         $log_action = ApplicationLogs::ACTION_MOVE;
                         $log_data = ($removed == "" ? "" : "from:{$removed};") . "to:{$wsid}";
                     } else {
                         $log_action = ApplicationLogs::ACTION_COPY;
                         $log_data = "to:{$wsid}";
                     }
                     if ($remain > 0 && ($obj instanceof ProjectTask || $obj instanceof ProjectMilestone)) {
                         $err++;
                     } else {
                         $obj->addToWorkspace($workspace);
                         ApplicationLogs::createLog($obj, $obj->getWorkspaces(), $log_action, false, null, true, $log_data);
                         $succ++;
                     }
                 }
             } else {
                 $err++;
             }
         } catch (Exception $e) {
             $err++;
         }
     }
     if ($err > 0) {
         flash_error(lang("error move objects", $err));
     } else {
         flash_success(lang("success move objects", $succ));
     }
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:89,代码来源:ObjectController.class.php


注:本文中的can_add函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。