Users can't delate and unpublish entry

8 years 3 months ago #185740 by ingede
My english is not very well, but maybe I can help someone.
I have CB ProfileBook (CB 1.7) on page - after I modified the code, user can not publish and delate entries on your own wall - moderator can only edit and delate.

In cb.profilebook.php find the code:
if ($isME || $iAmModerator) {

					//yes it is so display action links
					$base_url = $this->_getAbsURLwithParam($pagingParams);
					
					$return .= "<form name=\"actionForm".$k."\" id=\"actionForm".$k."\" method=\"post\" action=\"".$base_url."\" style=\"display:none;\">"
					."<input type=\"submit\" name=\"submitform\" value=\"submit\" style=\"display:none;\" />"
					."<input type=\"hidden\" name=\"".$this->_getPagingParamName("id")."\" value=\"".$item->pbid."\" />"
					."<input type=\"hidden\" name=\"".$this->_getPagingParamName("published")."\" id=\"published".$k."\" value=\"1\" />"
					."<input type=\"hidden\" id=\"formaction".$k."\" name=\"".$this->_getPagingParamName("formaction")."\" value=\"update\" />"
					."</form>";
					if($item->published==0) {
						$published=null; 
						$publishLink="<a href=\"javascript:document.actionForm".$k.".formaction".$k.".value='publish';document.actionForm".$k.".published".$k.".value=1;document.actionForm".$k.".submit();\">"._pb_Publish."</a>";
					}
					else {
						$published = "checked=\"checked\"";
						$publishLink="<a href=\"javascript:document.actionForm".$k.".formaction".$k.".value='publish';document.actionForm".$k.".published".$k.".value=0;document.actionForm".$k.".submit();\">"._pb_UnPublish."</a>";
					}

					$popform=null;
					$popform .= "<form name=\"adminForm".$k."\" id=\"adminForm".$k."\" method=\"post\" action=\"".$base_url."\">";
					$popform .= "<b>"._pb_Publish.":</b><input type=\"checkbox\" name=\"".$this->_getPagingParamName("published")."\" id=\"published".$k."\" value=\"1\" ".$published." />";
					$popform .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("id")."\" value=\"".$item->pbid."\" /><input type=\"hidden\" name=\"".$this->_getPagingParamName("formaction")."\" value=\"update\" />";
					$popform .= "<br /><b>"._pb_YourFeedback.":</b><br /><textarea class=\"inputbox\" name=\"".$this->_getPagingParamName("feedback")."\" style=\"height:75px;width:400px;overflow:auto;\" >".htmlspecialchars($item->feedback)."</textarea>";
					$popform .= "<br /><input type=\"submit\" value=\""._pb_Update."\" /></form>";					
					$return .= "<a href=\"javascript:if (confirm('".str_replace("'","\\'",_pb_DeleteAreYouSure)."')) { document.actionForm".$k.".formaction".$k.".value='delete';document.actionForm".$k.".submit(); }\">"._pb_Delete
					."</a> | ".$publishLink;
					if ($isME || ($iAmModerator && $item->feedback)) {
						$return .= " | <a href=\"javascript:void(0);\" name=\"pbFeedback".$k."\" id=\"pbFeedback".$k."\" onclick=\""
						.($iAmModerator && !$isME ? "if (confirm('".str_replace("'","\\'",_pb_EditOthersAreYouSure)."')) " : "")
						."return overlib('".str_replace(array("&","\\",'"',"<",">","'","\n","\r"), array("&amp;","\\\\","&quot;","&lt;","&gt;","\'","\\n","\\r"),$popform)."', STICKY, CAPTION,'"._pb_GiveFeedback."', CENTER,CLOSECLICK,CLOSETEXT,'"._UE_CLOSE_OVERLIB."',WIDTH,350, ANCHOR,'pbFeedback".$k."',ANCHORALIGN,'LR','UR');\">".($item->feedback ? _pb_EditFeedback : _pb_GiveFeedback)."</a> ";
					}
					$return .= $returnFavor;

				}

and replace this code:
if ($isME) {

					//yes it is so display action links
					$base_url = $this->_getAbsURLwithParam($pagingParams);
					
					$return .= "<form name=\"actionForm".$k."\" id=\"actionForm".$k."\" method=\"post\" action=\"".$base_url."\" style=\"display:none;\">"
					."<input type=\"submit\" name=\"submitform\" value=\"submit\" style=\"display:none;\" />"
					."<input type=\"hidden\" name=\"".$this->_getPagingParamName("id")."\" value=\"".$item->pbid."\" />"
					."<input type=\"hidden\" name=\"".$this->_getPagingParamName("published")."\" id=\"published".$k."\" value=\"1\" />"
					."<input type=\"hidden\" id=\"formaction".$k."\" name=\"".$this->_getPagingParamName("formaction")."\" value=\"update\" />"
					."</form>";

					$popform=null;
					$popform .= "<form name=\"adminForm".$k."\" id=\"adminForm".$k."\" method=\"post\" action=\"".$base_url."\">";
					$popform .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("published")."\" id=\"published".$k."\" value=\"1\" ".$published." />";
					$popform .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("id")."\" value=\"".$item->pbid."\" /><input type=\"hidden\" name=\"".$this->_getPagingParamName("formaction")."\" value=\"update\" />";
					$popform .= "<br /><b>"._pb_YourFeedback.":</b><br /><textarea class=\"inputbox\" name=\"".$this->_getPagingParamName("feedback")."\" style=\"height:75px;width:200px;overflow:auto;\" >".htmlspecialchars($item->feedback)."</textarea>";
					$popform .= "<br /><input type=\"submit\" value=\""._pb_Update."\" /></form>";					

					$return .= $publishLink;
				
					}
					
				if ($iAmModerator) {

					//yes it is so display action links
					$base_url = $this->_getAbsURLwithParam($pagingParams);
					
					$return .= "<form name=\"actionForm".$k."\" id=\"actionForm".$k."\" method=\"post\" action=\"".$base_url."\" style=\"display:none;\">"
					."<input type=\"submit\" name=\"submitform\" value=\"submit\" style=\"display:none;\" />"
					."<input type=\"hidden\" name=\"".$this->_getPagingParamName("id")."\" value=\"".$item->pbid."\" />"
					."<input type=\"hidden\" name=\"".$this->_getPagingParamName("published")."\" id=\"published".$k."\" value=\"1\" />"
					."<input type=\"hidden\" id=\"formaction".$k."\" name=\"".$this->_getPagingParamName("formaction")."\" value=\"update\" />"
					."</form>";
									
					$popform=null;
					$popform .= "<form name=\"adminForm".$k."\" id=\"adminForm".$k."\" method=\"post\" action=\"".$base_url."\">";
					$popform .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("published")."\" id=\"published".$k."\" value=\"1\" ".$published." />";
					$popform .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("id")."\" value=\"".$item->pbid."\" /><input type=\"hidden\" name=\"".$this->_getPagingParamName("formaction")."\" value=\"update\" />";
					$popform .= "<br /><b>"._pb_YourFeedback.":</b><br /><textarea class=\"inputbox\" name=\"".$this->_getPagingParamName("feedback")."\" style=\"height:75px;width:400px;overflow:auto;\" >".htmlspecialchars($item->feedback)."</textarea>";
					$popform .= "<br /><input type=\"submit\" value=\""._pb_Update."\" /></form>";					

					$return .= "<a href=\"javascript:if (confirm('".str_replace("'","\\'",_pb_DeleteAreYouSure)."')) { document.actionForm".$k.".formaction".$k.".value='delete';document.actionForm".$k.".submit(); }\">"._pb_Delete
					."</a> | ".$publishLink;
					if ($isME || ($iAmModerator && $item->feedback)) {
						$return .= " | <a href=\"javascript:void(0);\" name=\"pbFeedback".$k."\" id=\"pbFeedback".$k."\" onclick=\""
						.($iAmModerator && !$isME ? "if (confirm('".str_replace("'","\\'",_pb_EditOthersAreYouSure)."')) " : "")
						."return overlib('".str_replace(array("&","\\",'"',"<",">","'","\n","\r"), array("&amp;","\\\\","&quot;","&lt;","&gt;","\'","\\n","\\r"),$popform)."', STICKY, CAPTION,'"._pb_GiveFeedback."', CENTER,CLOSECLICK,CLOSETEXT,'"._UE_CLOSE_OVERLIB."',WIDTH,350, ANCHOR,'pbFeedback".$k."',ANCHORALIGN,'LR','UR');\">".($item->feedback ? _pb_EditFeedback : _pb_GiveFeedback)."</a> ";
					}
					$return .= $returnFavor;
				}
Answers also are published by default.

Important!
Fields: cb_pb_autopublish and cb_pb_enable must by unpublish.
Moderators: beatnantkrileon
Time to create page: 0.395 seconds

Facebook Twitter LinkedIn