예제 #1
0
파일: User.php 프로젝트: projectesIF/Sirius
    /**
     * create the fields necessary for synchronization
     * @author:     Albert Pérez Monfort (aperezm@xtec.cat)
     * @param: 	id of the note, id of the form and ids of the needed fields
     * @return:	 True if success and false otherwise
     */
    public function fieldsToDelete($args) {

        $fid = (isset($args['fid'])) ? $args['fid'] : null;
        $fmid = (isset($args['fmid'])) ? $args['fmid'] : null;
        // Security check
        if (!SecurityUtil::checkPermission('IWforms::', "::", ACCESS_READ)) {
            throw new Zikula_Exception_Forbidden();
        }
        //check user access to this form
        $access = ModUtil::func('IWforms', 'user', 'access', array('fid' => $fid));
        if ($access['level'] < 7) {
            LogUtil::registerError($this->__('You can not access this form to view the annotations'));
            // Redirect to the main site for the user
            return System::redirect(ModUtil::url('IWforms', 'user', 'main'));
        }
        $noteContent = ModUtil::apiFunc('IWforms', 'user', 'getAllNoteContents', array('fid' => $fid,
                    'fmid' => $fmid));
        if (!$noteContent) {
            LogUtil::registerError($this->__('Note content not found'));
            return System::redirect(ModUtil::url('IWforms', 'user', 'manage', array('fid' => $fid,
                                'order' => $order,
                                'ipp' => $ipp,
                                'init' => $init,
                                'filterValue' => $filterValue,
                                'filter' => $filter)));
        }
        $fieldsIdsNoteArray = array();
        foreach ($noteContent as $noteContentId) {
            $fieldsIdsNoteArray[] = $noteContentId['fndid'];
        }
        //get form fields
        $fields = ModUtil::apiFunc('IWforms', 'user', 'getAllFormFields', array('fid' => $fid,
                    'whereArray' => 'active|1'));
        if (!$fields) {
            LogUtil::registerError($this->__('Note fields not found'));
            return System::redirect(ModUtil::url('IWforms', 'user', 'manage', array('fid' => $fid,
                                'order' => $order,
                                'ipp' => $ipp,
                                'init' => $init,
                                'filterValue' => $filterValue,
                                'filter' => $filter)));
        }
        foreach ($fields as $field) {
            if ($field['fieldType'] < 10) {
                $fieldsIdsArray[] = $field['fndid'];
            }
        }
        // get the fields that must be deleted
        $toDelete = array_diff($fieldsIdsNoteArray, $fieldsIdsArray);
        $pntable = DBUtil::getTables();
        $c = $pntable['IWforms_note_column'];
        foreach ($toDelete as $delete) {
            $where = "$c[fmid]=$fmid AND $c[fndid]=$delete";
            if (!DBUTil::deleteWhere('IWforms_note', $where)) {
                return LogUtil::registerError($this->__('Error! delete attempt failed during field synchronization.'));
            }
        }
        return false;
    }
예제 #2
0
 public function esborra_membres($args) {
     //Comprovem que el paràmetre identitat hagi arribat
     if (!isset($args['gid'])) {
         return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.'));
     }
     // Security check
     if (!SecurityUtil::checkPermission('IWgroups::', '::', ACCESS_ADMIN)) {
         throw new Zikula_Exception_Forbidden();
     }
     $table = DBUtil::getTables();
     $c = $table['group_membership_column'];
     //Esborrem el registre de la taula de membres dels grups
     foreach ($args['uid'] as $id) {
         $where = "$c[gid]=$args[gid] AND $c[uid]=$id";
         if (!DBUTil::deleteWhere('group_membership', $where)) {
             return LogUtil::registerError($this->__('An error has occurred while trying to delete a record from the data base'));
         }
     }
     //Repetim el procés per al grup de la dreta
     foreach ($args['uid1'] as $id) {
         $where = "$c[gid]=$args[gid1] AND $c[uid]=$id";
         if (!DBUTil::deleteWhere('group_membership', $where)) {
             return LogUtil::registerError($this->__('An error has occurred while trying to delete a record from the data base'));
         }
     }
     //Retornem true ja que el procés ha finalitzat amb èxit
     return true;
 }