コード例 #1
0
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_function_EmbeddedAuthorizationList($params, &$smarty)
{
    global $current_company, $current_user;
    $object_type_id = $params['object_type_id'];
    $object_id = $params['object_id'];
    $ulf = new UserListFactory();
    $hlf = new HierarchyListFactory();
    $hotlf = new HierarchyObjectTypeListFactory();
    $alf = new AuthorizationListFactory();
    $alf->setObjectType($object_type_id);
    //$authorizing_obj = $alf->getObjectHandler()->getById( $object_id )->getCurrent();
    $tmp_authorizing_obj = $alf->getObjectHandler()->getById($object_id);
    if (is_object($tmp_authorizing_obj)) {
        $authorizing_obj = $tmp_authorizing_obj->getCurrent();
    } else {
        return FALSE;
    }
    //var_dump($authorizing_obj);
    unset($alf);
    $user_id = $authorizing_obj->getUserObject()->getId();
    $alf = new AuthorizationListFactory();
    $alf->getByObjectTypeAndObjectId($object_type_id, $object_id);
    foreach ($alf as $authorization_obj) {
        $authorization_data[] = array('id' => $authorization_obj->getId(), 'created_by_full_name' => $ulf->getById($authorization_obj->getCreatedBy())->getCurrent()->getFullName(), 'authorized' => $authorization_obj->getAuthorized(), 'created_date' => $authorization_obj->getCreatedDate(), 'created_by' => $authorization_obj->getCreatedBy(), 'updated_date' => $authorization_obj->getUpdatedDate(), 'updated_by' => $authorization_obj->getUpdatedBy(), 'deleted_date' => $authorization_obj->getDeletedDate(), 'deleted_by' => $authorization_obj->getDeletedBy());
        $user_id = $authorization_obj->getCreatedBy();
    }
    if ($authorizing_obj->getStatus() == 30) {
        //If the object is still pending authorization, display who its waiting on...
        $hierarchy_id = $hotlf->getByCompanyIdAndObjectTypeId($current_company->getId(), $object_type_id)->getCurrent()->getHierarchyControl();
        Debug::Text('Hierarchy ID: ' . $hierarchy_id, __FILE__, __LINE__, __METHOD__, 10);
        //Get Parents
        $parent_level_user_ids = $hlf->getParentLevelIdArrayByHierarchyControlIdAndUserId($hierarchy_id, $user_id);
        Debug::Arr($parent_level_user_ids, 'Parent Level Ids', __FILE__, __LINE__, __METHOD__, 10);
        if ($parent_level_user_ids !== FALSE and count($parent_level_user_ids) > 0) {
            Debug::Text('Adding Pending Line: ', __FILE__, __LINE__, __METHOD__, 10);
            foreach ($parent_level_user_ids as $parent_user_id) {
                $created_by_full_name[] = $ulf->getById($parent_user_id)->getCurrent()->getFullName();
            }
            $authorization_data[] = array('id' => NULL, 'created_by_full_name' => implode('<br>', $created_by_full_name), 'authorized' => NULL, 'created_date' => NULL, 'created_by' => NULL);
        }
    }
    $smarty->assign_by_ref('authorization_data', $authorization_data);
    $smarty->display('authorization/EmbeddedAuthorizationList.tpl');
}
コード例 #2
0
 function postSave()
 {
     //If status is pending auth (30) delete all authorization history, because they could
     //be re-verifying.
     if ($this->getStatus() == 30) {
         $alf = new AuthorizationListFactory();
         $alf->getByObjectTypeAndObjectId(90, $this->getId());
         if ($alf->getRecordCount() > 0) {
             foreach ($alf as $a_obj) {
                 //Delete the record outright for now, as marking it as deleted causes transaction issues
                 //and it never gets committed.
                 $a_obj->Delete();
                 /*
                 $a_obj->setDeleted(TRUE);
                 if ( $a_obj->isValid() ) {
                 	$a_obj->Save();
                 }
                 */
             }
         }
     }
     return TRUE;
 }
コード例 #3
0
 function clearHistory()
 {
     Debug::text('Clearing Authorization History For Type: ' . $this->getObjectType() . ' ID: ' . $this->getObject(), __FILE__, __LINE__, __METHOD__, 10);
     if ($this->getObjectType() === FALSE or $this->getObject() === FALSE) {
         Debug::text('Clearing Authorization History FAILED!', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     $alf = new AuthorizationListFactory();
     $alf->getByObjectTypeAndObjectId($this->getObjectType(), $this->getObject());
     foreach ($alf as $authorization_obj) {
         $authorization_obj->setDeleted(TRUE);
         $authorization_obj->Save();
     }
     return TRUE;
 }