Exemplo n.º 1
0
 public function definition()
 {
     global $CFG, $COURSE;
     $mform =& $this->_form;
     $annotations = $this->_customdata[0];
     $pageid = $this->_customdata[1]->pageid;
     $pagename = $this->_customdata[2];
     $currentuserid = $this->_customdata[3];
     $canlock = $this->_customdata[4];
     $orphaned = false;
     if ($pagename !== '') {
         $mform->addElement('hidden', 'page', $pagename);
         $mform->setType('page', PARAM_TEXT);
     }
     $mform->addElement('hidden', 'user', $currentuserid);
     $mform->setType('user', PARAM_INT);
     if (count($annotations != 0)) {
         usort($annotations, array('mod_ouwiki_annotate_form', 'ouwiki_internal_position_sort'));
         $editnumber = 1;
         foreach ($annotations as $annotation) {
             if (!$annotation->orphaned) {
                 $mform->addElement('textarea', 'edit' . $annotation->id, $editnumber, array('cols' => '40', 'rows' => '3'));
                 $mform->setDefault('edit' . $annotation->id, $annotation->content);
                 $editnumber++;
             } else {
                 $orphaned = true;
             }
         }
     }
     // Special field used in JavaScript
     $mform->addElement('static', 'endannotations', '', '<span id="end"></span>');
     // only display this checkbox if there are orphaned annotations
     if ($orphaned) {
         $mform->addElement('checkbox', 'deleteorphaned', get_string('deleteorphanedannotations', 'ouwiki'));
     }
     if ($canlock) {
         $mform->addElement('checkbox', 'lockediting', get_string('lockediting', 'ouwiki'));
         if (ouwiki_is_page_editing_locked($pageid)) {
             $mform->setDefault('lockediting', true);
         } else {
             $mform->setDefault('lockediting', false);
         }
     }
     $this->add_action_buttons();
 }
 function definition()
 {
     global $CFG, $COURSE;
     $mform =& $this->_form;
     $annotations = $this->_customdata[0];
     $pageid = $this->_customdata[1]->pageid;
     $pagename = $this->_customdata[2];
     $currentuserid = $this->_customdata[3];
     $orphaned = false;
     $mform->addElement('hidden', 'page', $pagename);
     $mform->addElement('hidden', 'user', $currentuserid);
     $mform->addElement('header', 'annotations', get_string('annotations', 'ouwiki'));
     if (count($annotations != 0)) {
         usort($annotations, array("mod_ouwiki_annotate_form", "ouwiki_internal_position_sort"));
         $editnumber = 1;
         foreach ($annotations as $annotation) {
             if (!$annotation->orphaned) {
                 $mform->addElement('textarea', 'edit' . $annotation->id, $editnumber, array('cols' => '40', 'rows' => '3'));
                 $mform->setDefault('edit' . $annotation->id, $annotation->content);
                 $editnumber++;
             } else {
                 $orphaned = true;
             }
         }
     }
     // only display this checkbox if there are orphaned annotations
     if ($orphaned) {
         $mform->addElement('checkbox', 'deleteorphaned', get_string('deleteorphanedannotations', 'ouwiki'));
     }
     $mform->addElement('checkbox', 'lockediting', get_string('lockediting', 'ouwiki'));
     if (ouwiki_is_page_editing_locked($pageid)) {
         $mform->setDefault('lockediting', true);
     } else {
         $mform->setDefault('lockediting', false);
     }
     $this->add_action_buttons();
 }
Exemplo n.º 3
0
/**
 * Sets the page editing lock according to $lock
 *
 * @param integer $pageid Wiki page id
 * @param bool $lock
 * @return nothing
 */
function ouwiki_lock_editing($pageid, $lock)
{
    global $DB;
    $locked = ouwiki_is_page_editing_locked($pageid);
    if ($lock != $locked) {
        $dataobject->id = $pageid;
        $dataobject->locked = $lock ? 1 : 0;
        try {
            $DB->update_record('ouwiki_pages', $dataobject);
        } catch (Exception $e) {
            ouwiki_dberror($e, 'Could not change the lock status for this wiki page');
        }
    }
}